-
-
Save maxim/0828b60c2b2023677b4c to your computer and use it in GitHub Desktop.
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
LOG=log/resque.log PIDFILE=tmp/pids/resque.pid config/resque_worker & |
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
#!/usr/bin/env ruby | |
require File.expand_path('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