Nginx Tornado and Flask - What's a good start/stop script and keep-alive method
-
20-03-2021 - |
Pregunta
I've set up a Flask application to run on a tornado server backed by nginx. I've written a couple of bash scripts to reload server configuration when a new version is deployed, but I am unhappy with them. Basically what I have is:
to start the server (assuming in project root)
# this starts the tornado-flask wrapper
python myapp.py --port=8000 # .. some more misc settings
# this starts nginx
nginx
to stop it
pkill -f 'myapp.py'
nginx -s stop
to restart
cd $APP_ROOT
./script/stop && ./script/start
Many times these don't work smoothly and I need to manually run the commands. Also, I'm looking for a way to verify the service is alive, and start it up if it's down. Thoughts? Thanks.
Solución
Supervisor is what you are looking for.
It's what I use to manage my Tornado apps along with some other processing daemons. It will daemonize, handle logging, pid files... Pretty much everything you need.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow