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
function buildJob( data ) { | |
var params = { | |
'class': CLASS_NAME, | |
args: [ {"id": data} ] | |
}; | |
return [ | |
'rpush', | |
'resque:queue:'+ QUEUE_NAME, | |
JSON.stringify( params ) |
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
03:54+00:00 app[worker.1]: *** got: (Job{jobs} | Job | [1, 100]) | |
03:55+00:00 app[worker.1]: Processed 1 | |
03:56+00:00 app[worker.1]: Processed 2 | |
03:57+00:00 app[worker.1]: Processed 3 | |
03:58+00:00 app[worker.1]: Processed 4 | |
03:59+00:00 app[worker.1]: Processed 5 | |
04:00+00:00 app[worker.1]: Processed 6 | |
04:01+00:00 app[worker.1]: Processed 7 | |
04:02+00:00 app[worker.1]: Processed 8 | |
04:03+00:00 app[worker.1]: Processed 9 |
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
07:36+00:00 app[worker.1]: *** got: (Job{jobs} | Job | [1, 100]) | |
07:37+00:00 app[worker.1]: Processed 1 | |
07:38+00:00 app[worker.1]: Processed 2 | |
07:39+00:00 app[worker.1]: Processed 3 | |
07:40+00:00 app[worker.1]: Processed 4 | |
07:41+00:00 app[worker.1]: Processed 5 | |
07:42+00:00 app[worker.1]: Processed 6 | |
07:43+00:00 app[worker.1]: Processed 7 | |
07:44+00:00 app[worker.1]: Processed 8 | |
07:45+00:00 app[worker.1]: Processed 9 |
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
# Registers the various signal handlers a worker responds to. | |
# | |
# TERM: Shutdown immediately, stop processing jobs. | |
# INT: Shutdown immediately, stop processing jobs. | |
# QUIT: Shutdown after the current job has finished processing. | |
# USR1: Kill the forked child immediately, continue processing jobs. | |
# USR2: Don't process any new jobs | |
# CONT: Start processing jobs again after a USR2 | |
def register_signal_handlers | |
trap('TERM') { shutdown! } |
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
task "resque:pause" => :environment do | |
Resque.redis.set "resque_paused", true | |
puts "Resque paused." | |
end | |
task "resque:resume" => :environment do | |
Resque.redis.set "resque_paused", false | |
puts "Resque resumed." | |
end |