Skip to content

Instantly share code, notes, and snippets.

@Corei13
Last active August 29, 2015 13:56
Show Gist options
  • Save Corei13/8912083 to your computer and use it in GitHub Desktop.
Save Corei13/8912083 to your computer and use it in GitHub Desktop.
#nohup bash ./run_worker.sh $1 $2
#$1 = number of workers
#$2 = reset?
if [ "$2" == "reset" ]; then
php reset.php;
fi
for (( i = 0; i < $1; i++ )); do
php worker.php $i &
PID[$i]=$!;
done
while [[ true ]]; do
sleep 15;
for (( i = 0; i < $1; i++ )); do
if ! ps -p ${PID[$i]} > /dev/null
then
# worker[i] is down, restarting...
php worker.php $i &
PID[$i]=$!;
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment