2

I am trying to start gunicorn on bootup of my machine but when I check the status of my service after enabling and starting it I get an error starting start-limit-hit. I have tried using sudo systemctl restart ssh as suggested in How to resolve service start limit hit. This is my .service file:

[Unit]
Requires=myproject.socket
After = network.target

[Service]
Restart=always
User=ubuntu
WorkingDirectory=/home/ubuntu/myproject
ExecStart=/home/ubuntu/myproject/venv36/bin/gunicorn -w 1 -b 0.0.0.0:8080 wsgi:$
Type=simple


[Install]
WantedBy=multi-user.target

My .socket file:

[Socket]
ListenStream=/run/myproject/socket

[Install]
WantedBy=sockets.target
Yurij Goncharuk
  • 4,177
  • 2
  • 19
  • 36
Connor McCann
  • 29
  • 1
  • 1
  • 2
  • 1
    You can run `systemctl reset-failed ` to get rid of the start-limit error. Regarding your `.service` file I would suggest to remove the whitespaces in `After = network.target`, although I'm not sure if that will help starting the service. – eblock Apr 23 '19 at 09:30
  • 1
    I removed the spaces and ran `systemctl reset-failed ` but still got the start-limit-hit error – Connor McCann Apr 23 '19 at 09:38
  • ok, just to be clear, you did replace `` with the actual name of your unit, right? – eblock Apr 23 '19 at 10:05
  • yeah! I used `systemctl reset-failed myproject` – Connor McCann Apr 23 '19 at 10:13
  • Since you've not told anyone _how the service is failing_, what the error messages logged are, people are going to flounder around blindly with the problem diagnosis. For all that the world knows, you too could be having the error in https://unix.stackexchange.com/q/501590/5132 . [Always follow the standard litany](http://jdebp.uk./FGA/problem-report-standard-litany.html). – JdeBP Dec 17 '19 at 13:54

1 Answers1

3

You have Restart=always and a Type of simple, so in case the program specified in ExecStart is a daemon that forks another process and exits, your app will be considered not-active -> it will restart until it hits the limit.

You should either pass a parameter for the program to remain in the foreground, or change the Type to forking. After that run systemctl reset-failed myproject and start it.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
FloriOn
  • 315
  • 1
  • 14
  • This is not the case for Gunicorn, as M. Schaller no doubt remembers from https://unix.stackexchange.com/a/501592/5132 . `Type=forking` is a bad idea that is best avoided, moreover. – JdeBP Dec 17 '19 at 13:49