Help with gunicorn.service file setup on Ubuntu 18.04?

November 17, 2019 513 views
Django

Hi there, I have been following the Gunicorn/Django tutorial to set up the Gunicorn service on Ubuntu 18.04 and keep getting errors. The gunicorn.service file contains as set out below:

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

[Service]
User=garryjw
Group=www-data
WorkingDirectory=/home/garryjw/portfolio-project/portfolio
ExecStart=/home/garryjw/myvenv/bin/gunicorn \
–access-logfile - \
–workers 3 \
–bind unix:/run/gunicorn.sock \
portfolio.wsgi:application

[Install]
WantedBy=multi-user.target

However, when doing a systemctl status gunicorn check results in the following errors:

● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-11-17 09:10:07 UTC; 38s ago
Process: 18487 ExecStart=/home/garryjw/bin/gunicorn –access-logfile - –workers 3 –bind unix:/run/gunicorn.sock portfolio.wsgi:application (code=exited, status
Main PID: 18487 (code=exited, status=203/EXEC)

Nov 17 09:10:07 djangowalaw systemd[1]: Started gunicorn daemon.
Nov 17 09:10:07 djangowalaw systemd[18487]: gunicorn.service: Failed to execute command: No such file or directory
Nov 17 09:10:07 djangowalaw systemd[18487]: gunicorn.service: Failed at step EXEC spawning /home/garryjw/bin/gunicorn: No such file or directory
Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Failed with result ‘exit-code’.
Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Start request repeated too quickly.
Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Failed with result 'exit-code’.
Nov 17 09:10:07 djangowalaw systemd[1]: Failed to start gunicorn daemon.

Anyone able to help?

1 Answer

Hello,

As far as I can see the service is not starting as the following directory /home/garryjw/bin/ does not exist.

What I could suggest here is to make sure that the directory that you’ve specified in your unit file actually exists:

ls -l /home/garryjw/myvenv/bin/gunicorn

If the directory does not exist, then I would recommend ExecStart=/home/garryjw/myvenv/bin/gunicorn to match the correct path to the gunicorn binary.

Let me know how it goes!
Regards,
Bobby

Have another answer? Share your knowledge.