Created
September 27, 2011 15:54
-
-
Save mrichie/1245457 to your computer and use it in GitHub Desktop.
make Resque scheduler write to PIDFILE
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
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