Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top