Skip to content

Instantly share code, notes, and snippets.

@maxim
Created July 16, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxim/0828b60c2b2023677b4c to your computer and use it in GitHub Desktop.
Save maxim/0828b60c2b2023677b4c to your computer and use it in GitHub Desktop.
LOG=log/resque.log PIDFILE=tmp/pids/resque.pid config/resque_worker &
#!/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