Today I wanna talk about a lesser known trick used for making deployments on your server being managed by Supervisor with zero downtime. Zero Downtime, you ask what it is? Well, I didn't know it either until just now. I'll explain it with an example of supervisor usage.
If you use supervisor to manage and monitor your processes, then when you deploy changes on your production server, what you usually do is that you run the below command:
sudo supervisorctl reload
But a disadvantage of using this command is that there's a downtime of approximately 10 - 15 seconds, might be more sometimes, I didn't time it yet. So I wanted to avoid it because once my manager was using the site while I was making the deployment, so he messaged me on Slack instantly because of it.
So instead of doing the above, you can do this instead:
sudo supervisorctl pid gunicorn | sudo xargs kill -s HUP
Here, the name of program managed by supervisor was gunicorn
, but it can be anything in your case, just replace it with your program's name.
Using this, your changes will be reflected on the server without any sort of server error being shown to the users connected to your website, it'll be seamless, that is what's called Zero Downtime.
That was all what I wanted share with you all in this mini post, see ya.