Skip to content

Instantly share code, notes, and snippets.

@danigosa
Created July 23, 2014 12:28
Show Gist options
  • Save danigosa/3fa853a69d28ffef5453 to your computer and use it in GitHub Desktop.
Save danigosa/3fa853a69d28ffef5453 to your computer and use it in GitHub Desktop.
Supervise processes
#!/bin/bash
# Script to supervise processes
# Full supervisord config here: https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps
while true
do
SERVICE="$1"
RESULT=`killall -q -0 $1 && echo running`
if [ "${RESULT:-null}" = null ]; then
echo "Not running!, Starting process..."
# Start targeted process here!
sudo /etc/init.d/celeryd start
sleep 1
else
echo "Running!"
sleep "$2"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment