Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jdunmore/9641297 to your computer and use it in GitHub Desktop.
Save jdunmore/9641297 to your computer and use it in GitHub Desktop.
#!/bin/bash
excludedprocesses=(somethingidontwant:something_instance-0 somethingelse)
for f in `supervisorctl status | awk '{print $1}' `; do
echo "found $f"
if [[ ${excludedprocesses[*]} =~ $f ]]
then
echo "Exluding $f as a restart candidate"
else
status=`supervisorctl status $f | awk '{print $2}'`
if [ "$status" == "RUNNING" ] ; then
echo "$f is running"
uptimedays=`supervisorctl status $f | grep day`
timepart=`supervisorctl status $f | awk '{print $NF}' | awk -F ":" '{print $1}'`
if [[ -n $uptimedays ]] |[[ $timepart -gt 5 ]] ;
then
echo "Restarting $f due to uptime"
`supervistorctl restart $f`
fi
fi
fi
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment