-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
121c8f9
commit 2ae0cd3
Showing
1 changed file
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
#!/bin/bash | ||
source ./scripts/load-config | ||
while true; do | ||
COUNT=${COUNT:-1} rails resque:workers | ||
|
||
run_resque=1 | ||
resque_pid=0 | ||
|
||
exit_gracefully() { | ||
run_resque=0 | ||
kill -SIGQUIT $(pgrep -P $resque_pid) | ||
kill -SIGTERM $resque_pid | ||
} | ||
|
||
trap exit_gracefully SIGTERM SIGINT | ||
|
||
mkdir -p tmp/pids &> /dev/null | ||
while [[ $run_resque -eq 1 ]]; do | ||
rm -rf tmp/pids/resque.pid &> /dev/null | ||
COUNT=${COUNT:-1} rails resque:workers & | ||
resque_pid=$! | ||
while ps -p $resque_pid > /dev/null; do sleep 1s; done | ||
done |