Sam B.
Sam B.

Reputation: 3043

gunicorn [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring

I'm setting up django on digitalocean, they have a setup rule that works this time though gunicorn won't work.

First step is setting up the gunicorn service using this command sudo nano /etc/systemd/system/gunicorn.service

and the content

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/webapp/prestige
ExecStart=/home/sammy/webapp/envs/prestige/bin/gunicorn \
        --access-logfile - \
        --workers 3 \
        --bind unix:/run/gunicorn.sock \
        prestige.wsgi:application

[Install]
WantedBy=multi-user.target

and the socket file sudo nano /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

note that this directory

/home/sammy/webapp/prestige

is the main folder directory of django with manage.py so basically if I cd into it I can run python manage.py runserver and it works.

this is the folder for the virtualenv

/home/sammy/webapp/envs/prestige

now when I run the start gunicorn command I get this

(prestige) sammy@prestige:~/webapp$ sudo systemctl start gunicorn.socket
Failed to start gunicorn.socket: Unit gunicorn.socket is not loaded properly: Invalid argument.
See system logs and 'systemctl status gunicorn.socket' for details.

if you check the status

(prestige) sammy@prestige:~/webapp$ sudo systemctl status gunicorn.socket
● gunicorn.socket - gunicorn daemon
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
May 17 07:25:18 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:25:18 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:33:32 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:33:32 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:34:09 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:34:09 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:53:41 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:53:41 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:56:59 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:56:59 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.

No idea what's going on.

Upvotes: 1

Views: 3629

Answers (2)

Samer Saied
Samer Saied

Reputation: 31

ENABLE gunicorn.socket after start it

sudo systemctl ENABLE gunicorn.socket

and make sure you link socket with gunicorn.service

Upvotes: 0

Sam B.
Sam B.

Reputation: 3043

Found out the hard way that if you put the wrong code for the service or socket for gunicorn it bugs out. After just deleting the droplet and starting again it went on smoothly.

Upvotes: 1

Related Questions