Restarting supervisord processes in parallel

At Private Packagist we manage some of our background processes with Supervisor. It comes with a command line interface supervisorctl which has an option to restart a group of processes. The way this works is by sending the respective signal to all processes, waiting for them to terminate and then starting them all up again. The way we called this so far is as follows:

supervisorctl signal INT packagist:*
supervisorctl restart packagist:*

As a consequence if you have some processes which take a while before they shut down all other process are already shut down and won’t get started up again yet. For us this happens because some processes may be in the middle of some work we don’t want to interrupt. So instead we want all processes to start up again immediately after they are stopped. My solution uses GNU parallel to run supervisorctl restart in parallel for each of our processes:

supervisorctl signal INT packagist:*
supervisorctl avail | cut -f 1 -d " "|grep packagist:| parallel supervisorctl restart {}

Hope this can be of help to someone looking for a solution to the same problem!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s