Skip to content

Instantly share code, notes, and snippets.

@mrichie
Created September 27, 2011 15:54
Show Gist options
  • Save mrichie/1245457 to your computer and use it in GitHub Desktop.
Save mrichie/1245457 to your computer and use it in GitHub Desktop.
make Resque scheduler write to PIDFILE
require 'resque/tasks'
require 'resque_scheduler/tasks'
task "resque:setup" => :environment
desc "Start Resque Scheduler"
task 'resque:scheduler' => :scheduler_setup do
require 'resque'
require 'resque_scheduler'
File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid.to_s } if ENV['PIDFILE']
Resque::Scheduler.dynamic = true if ENV['DYNAMIC_SCHEDULE']
Resque::Scheduler.verbose = true if ENV['VERBOSE']
Resque::Scheduler.run
end
task :scheduler_setup do
if ENV['INITIALIZER_PATH']
load ENV['INITIALIZER_PATH'].to_s.strip
else
Rake::Task['resque:setup'].invoke
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment