I have a load balancer/reverse proxy (either nginx or cherokee, does not matter which) deployed on my server and it points to multiple background webserver processes (either gunicorn or cherrypy, does not matter which) in a round-robin set-up.
In order to minimize downtime, I have a webserver restart script that kills a specific webserver process (out of say 8 processes) and then starts it up immediately again; and then goes on to the next webserver process (kill it, then start it up again) so at any moment in time, there will always be at least 7 processes available for my reverse proxy to point to.
This is great; but is there a way to "perfect" this process such that I do not get 502 Bad gateway at all? 502 gateway happens when a user so happens to be on the site and using a webserver process that gets temporarily killed and revived.
Obviously, the reason why I need the restart script is for deployment of new python code in my python application (running on either gunicorn or cherrypy).