Skip to content

Instantly share code, notes, and snippets.

@maxim
Created July 29, 2011 22:15
Show Gist options
  • Select an option

  • Save maxim/1114857 to your computer and use it in GitHub Desktop.

Select an option

Save maxim/1114857 to your computer and use it in GitHub Desktop.
Resque worker script for development, written for takeup
# 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`"
#!/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