The scenario:
- System running on a server consisting of a Python/Flask web application and background tasks using Celery
- Both web application and celery workers are run as upstart jobs (Web app behind Nginx)
Deployment to production is done with a script that:
- Stop the upstart jobs
- Push code to server
- Run any db migrations
- Start the upstart jobs
How can I enhance the deployment script so it does the following?:
- Tell the celery worker to stop accepting tasks
- Wait until any currently running celery tasks are finished
- Stop the upstart jobs
- Push code to server
- Run any db migrations
- Start the upstart jobs