This shell script runs forever and checks if the rails worker is running and if not it starts it again:
while : do if ps ax | grep -v grep | grep 'rails worker' > /dev/null then echo "service running, everything is fine" sleep 5 else echo "service is not running. Lets start again" cd $APP_ROOT $BUNDLE exec unicorn_rails -D -c $CONF echo "restarted on $(cat /rails/pids/unicorn.pid)" sleep 15 fi done