Which log should I use when debugging starting a web server on boot

Ubuntu 18.04

I'm trying to make Gunicorn web server start on boot.

/etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
[Service]
# the specific user that our service will run as
User=pcask
Group=pcask
WorkingDirectory=/home/michael/PycharmProjects/pcask/pcask
ExecStart=gunicorn pcask.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target

Permissions

pcask@tmpgmv:~/pcask/venv/lib/python3.8/site-packages$ ls -la |grep gunicorn
drwxrwxr-x 7 pcask pcask 4096 Jul 28 19:32 gunicorn
drwxrwxr-x 2 pcask pcask 4096 Jul 28 19:32 gunicorn-20.0.4.dist-info

On reboot the server is not running. Namely when I open my websie, it shows 502 Bad gateway. This means that Gunicorn is not running.

Could you tell me whether there is an error log where I can see what went wrong when this service file was used on boot. And whether it was used at all.

ADDED LATER

$ sudo journalctl -u gunicorn.service
[sudo] password for pcask:
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2020-08-14 12:36:57 MSK; 1min 11s ago Process: 439 ExecStart=/home/pcask/pcask/venv/lib/python3.8/site-packages/gunicorn pcask.wsgi:application (code=exited, status=203/EXEC) Main PID: 439 (code=exited, status=203/EXEC)
Aug 14 12:36:57 tmpgmv systemd[1]: Started gunicorn daemon.
Aug 14 12:36:57 tmpgmv systemd[439]: gunicorn.service: Failed to execute command: Permission denied
Aug 14 12:36:57 tmpgmv systemd[439]: gunicorn.service: Failed at step EXEC spawning /home/pcask/pcask/venv/lib/python3.8/site-packages/gunicorn: Permission denied
Aug 14 12:36:57 tmpgmv systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Aug 14 12:36:57 tmpgmv systemd[1]: gunicorn.service: Failed with result 'exit-code'.

1 Answer

systemd uses its own logging. The command for viewing it is

journalctl 

You can use

journalctl -u gunicorn.service

to trace a specific service.

Some other examples:

journalctl --since="2020-01-01 10:00:00"
journalctl --since "30 min ago"
journalctl _PID=1000
  • make sure the service is active. Check sudo systemctl status gunicorn.service and if inactive you can use sudo systemctl enable gunicorn to make it active.

  • make sure the service starts after all other required services are started. Starting gunicon before nginx or your network is up wont work. Something worth noting: your unit is lacking a After=network.target in the [UNIT] section.

Assuming your gunicorn works when manually started you do not need the nginx logs but just in case those are:

/var/log/nginx/access.log
/var/log/nginx/error.log
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like