Created
July 29, 2011 22:15
-
-
Save maxim/1114857 to your computer and use it in GitHub Desktop.
Resque worker script for development, written for takeup
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
| # This is what would be in your takeup manifest to run this script. | |
| # Find takeup at http://github.com/maxim/takeup | |
| - name: "resque" | |
| pid_file: ":project_root/tmp/pids/resque.pid" | |
| start: "LOG=':project_root/log/resque.log' PIDFILE=:pid_file :support_root/resque_worker &" | |
| stop: "kill `cat :pid_file`" |
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
| #!/usr/bin/env ruby | |
| require 'config/environment' | |
| require 'resque' | |
| if ENV['LOG'] | |
| log = File.new(ENV['LOG'], 'a') | |
| log.sync = true | |
| STDOUT.reopen log | |
| end | |
| worker = Resque::Worker.new('*') | |
| worker.verbose = true | |
| worker.log "Starting worker #{worker}" | |
| begin | |
| if ENV['PIDFILE'] | |
| File.open(ENV['PIDFILE'], 'w') { |f| f << worker.pid } | |
| end | |
| worker.work(ENV['INTERVAL'] || 5) | |
| ensure | |
| File.delete(ENV['PIDFILE']) if ENV['PIDFILE'] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment