Search code examples
nginxflaskgunicornubuntu-18.04

How to make sure that a process on Gunicorn3 runs continuously?


I have a flask app deployed on a Ubuntu server. I use Nginx, and Gunicorn3. I know from this StackOverflow post that one of the correct ways to have the app running continuously on the server is to use something like:

gunicorn3 app:application --workers 3 --bind=127.0.0.1:1001 --daemon

But to be completely safe, since there are many other processes running on that server, I would like to find a way to check whether this process IS indeed running, and if it is NOT running (for whatever reasons) then to start it again.

In addition to that question, to make the app working at reboot, I use the following cronjob:

@reboot bash ~/restart_processes.sh

Where the .sh file executes the command line given above for starting Gunicorn3. Is this good practice or is there a better way to achieve the same result?

Thank you! Kind regards,


Solution

  • I always use to deploy it in production with supervisorctl + nginx. Check this tutorial . You can simply start, restart or stop with a command.