My application is developed with Flask and uses buildout to handle dependency isolation. I plan to use Gunicorn and supervisord as wsgi container and process manager, in front of which there is Nginx doing load balancing. Here is the problem when deploying a new version of the application: everything is builtout in a subfolder, how to restart the gunicorn server so that the version switching can take place gracefully?
I come up with some solutions of course:
-
Ditch gunicorn and superviosrd, and turn to apache mod_wsgi, so when deploying a new version I could simply change the folder in .wsgi file and the server will restart.
-
Use virtualenv and install gunicorn, supervisord, as well as my application package in it, so when switching version I just restart it using supervisorctl.
Is there a ‘pure’ buildout way that can accomplish this situation? Or any in-use production solutions will all be appreciated.
Thanks in advance.
Just like with your point-mod_wsgi-at-a-different-folder solution, you can do the same with gunicorn/buildout. Just set up your latest buildout in a different directory, stop the old gunicorn and start the new.
There’ll be a short delay between stopping the one and starting the other, of course.
Alternative: set up the new one with a different port number, change the nginx config and kick ngnix if you really want zero downtime-seconds.