1

I'm deploying on digital-ocean, on Ubuntu 18.04.3. This is my first time deploying a Django application so I have lots of exposure to this new deployment stuff but next to no ability. When I start and enable my gunicorn service through systemctl then check the status it returns

jordan@ubuntu-s-1vcpu-1gb-tor1-01:~/jycs/jycs/jycs$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-08-01 14:02:50 UTC; 7min ago
 Main PID: 20214 (gunicorn)
    Tasks: 4 (limit: 1152)
   CGroup: /system.slice/gunicorn.service
           ├─20214 /home/jordan/jycs/env/bin/python /home/jordan/jycs/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock jycs.ws
           ├─20230 /home/jordan/jycs/env/bin/python /home/jordan/jycs/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock jycs.ws
           ├─20232 /home/jordan/jycs/env/bin/python /home/jordan/jycs/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock jycs.ws
           └─20233 /home/jordan/jycs/env/bin/python /home/jordan/jycs/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock jycs.ws

Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20214] [INFO] Starting gunicorn 20.0.4 Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20214] [INFO] Listening at: unix:/run/gunicorn.sock (20214) Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20214] [INFO] Using worker: sync Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20230] [INFO] Booting worker with pid: 20230 Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20232] [INFO] Booting worker with pid: 20232 Aug 01 14:02:50 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: [2020-08-01 14:02:50 +0000] [20233] [INFO] Booting worker with pid: 20233 Aug 01 14:02:51 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: /home/jordan/jycs/jycs Aug 01 14:02:51 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: /home/jordan/jycs/jycs Aug 01 14:02:51 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: /home/jordan/jycs/jycs Aug 01 14:10:25 ubuntu-s-1vcpu-1gb-tor1-01 gunicorn[20214]: - - [01/Aug/2020:14:10:25 +0000] "GET / HTTP/1.1" 400 143 "-" "curl/7.58.0"

and then we do sudo journalctl -u gunicorn.socket

jordan@ubuntu-s-1vcpu-1gb-tor1-01:~/jycs/jycs/jycs$ sudo journalctl -u gunicorn.socket
-- Logs begin at Fri 2020-07-31 13:36:05 UTC, end at Sat 2020-08-01 14:04:00 UTC. --
Jul 31 17:22:11 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Jul 31 17:24:10 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Jul 31 17:36:03 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Jul 31 19:22:37 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Jul 31 19:44:31 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Jul 31 19:51:44 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Jul 31 21:13:22 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Jul 31 22:00:40 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Aug 01 02:45:27 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Aug 01 02:50:19 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Aug 01 04:45:14 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Aug 01 04:45:40 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Aug 01 05:11:02 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.
Aug 01 06:04:45 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
Aug 01 14:02:38 ubuntu-s-1vcpu-1gb-tor1-01 systemd[1]: Listening on gunicorn socket.

My gunicorn.service file located at /etc/systemd/system/gunicorn.service

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

[Service] User=jordan Group=www-data WorkingDirectory=/home/jordan/jycs/jycs ExecStart=/home/jordan/jycs/env/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
jycs.wsgi:application

[Install] WantedBy=multi-user.target

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

[Unit]
Description=gunicorn socket

[Socket] ListenStream=/run/gunicorn.sock

[Install] WantedBy=sockets.target

When I try curl it returns

jordan@ubuntu-s-1vcpu-1gb-tor1-01:~/jycs/jycs/jycs$ jordan@ubuntu-s-1vcpu-1gb-tor1-01:~/jycs/jycs/jycs$ curl --unix-socket /run/gunicorn.sock localhost

<!doctype html> <html lang="en"> <head> <title>Bad Request (400)</title> </head> <body> <h1>Bad Request (400)</h1><p></p> </body> </html>

user.dz
  • 48,105
  • How did you solve this? – yung peso Apr 29 '21 at 03:14
  • @Dre I don't recall exactly how I solved it, Ive since moved to working with FastAPI and Vue but iirc there was some hints in the logs. You may also find some more luck if you narrow your query down to something like “gunicorn service-start-limit-hit” –  Apr 30 '21 at 23:23

1 Answers1

0

Basically, the "start-limit-hit" message is a red herring - service start tries to start which ever service name you provide multiple times, and if after the fifth failed attempt (for me, at least) it crashes out on the sixth attempt with "start-limit-hit". You'll need to investigate the actual syslog (possibly /var/log/syslog) to see what the real errors are that are preventing the service from starting on attempts 1-5.