Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daiguoliangfirst/f7f41fb43a4ba092cb89 to your computer and use it in GitHub Desktop.
Save daiguoliangfirst/f7f41fb43a4ba092cb89 to your computer and use it in GitHub Desktop.
#!/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 `sudo /usr/local/bin/supervisorctl status | grep "$PROGRAM:" | awk '{print $1}'`; do
sudo /usr/local/bin/supervisorctl restart $f
while [ 1 ]; do
sleep $TIME_BETWEEN_RUNNING_CHECKS
status=`sudo /usr/local/bin/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
@daiguoliangfirst
Copy link
Author

make $PROGRAM precise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment