Last active
August 29, 2015 13:56
-
-
Save Corei13/8912083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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