rendered paste body#!/bin/bash# a shell script that keeps looping until an exit code is given# if it's a 0, immediatly restart# if it's an error, pause, then restart# and one particular code, exit cleanly.## Run the PHP script. What it returns decides on what happens nextnice php -f cli-beanstalk-worker.phpERR=$?## Possibilities# 0 - unplanned restart (aka exit;)# 1-97 - unplanned restart# 98 - planned restart# 99 - planned stop, exit.# 100 - unplanned restart if [ $ERR -eq 97 ]then # a planned pause, then restart echo "PLANNED_PAUSE - wait 2"; sleep 2; exec $0;fiif [ $ERR -eq 98 ]then # a planned restart echo "PLANNED_RESTART"; exec $0;fiif [ $ERR -eq 99 ]then # planned complete exit echo "PLANNED_SHUTDOWN"; #echo "sleep for a couple of secs first" #sleep 2 #echo DONE, $$ exit 0;fi# unplanned exit, pause, and restartecho "unplanned restart: err:" $ERR;echo "sleeping for (2) secs. - normally 10?"sleep 2exec $0