-
-
Save enixdark/d46fbbf878727eae8c90fbc1ffe7cfcc to your computer and use it in GitHub Desktop.
Rolling restart supervisord watched processes. Since every restart it waits for "$status" == "RUNNING", it's safer that simply running /etc/init.d/supervisor restart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: ./supervisor-rolling-restart [supervised-process-name] | |
# | |
PROGRAM=$1 | |
# Time in seconds. | |
TIME_BETWEEN_RUNNING_CHECKS=0.5 | |
TIME_BETWEEN_RESTARTS=1 | |
for f in `supervisorctl status | grep "$PROGRAM" | awk '{print $1}'`; do | |
supervisorctl restart $f | |
while [ 1 ]; do | |
sleep $TIME_BETWEEN_RUNNING_CHECKS | |
status=`supervisorctl status $f | awk '{print $2}'` | |
if [ "$status" == "RUNNING" ] ; then | |
echo $f restarted | |
break | |
elif [ "$status" == "FATAL" ] ; then | |
echo "Error during restart of $f ($status). Stopping rolling update." | |
exit 1 | |
else | |
echo "Now: $status" | |
fi | |
done | |
sleep $TIME_BETWEEN_RESTARTS | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment