Created
April 23, 2011 06:10
-
-
Save sdhull/938386 to your computer and use it in GitHub Desktop.
rake task (including contents of old clock.rb file) to start/stop/restart clockwork.rb
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
namespace :clockwork do | |
desc 'Start the clockwork daemon' | |
task :start => :environment do | |
pid = fork do | |
$stdout.reopen("/dev/null") | |
$stdout.sync = true | |
$stderr.reopen($stdout) | |
include Clockwork | |
handler do |job_class| | |
Resque.enqueue(job_class) | |
end | |
every(30.seconds, Gameday::FrequentUpdates) | |
every(1.day, Gameday::DailyJob, :at => "01:30") | |
run | |
end | |
Process.detach(pid) | |
File.open("./tmp/clockwork_#{Rails.env}_pid.txt", "w") do |file| | |
file << pid | |
end | |
end | |
desc "Stop the clockwork daemon" | |
task :stop => :environment do | |
pid = File.read("./tmp/clockwork_#{Rails.env}_pid.txt").to_i | |
Process.kill(1, pid) | |
end | |
desc 'restart the clockwork daemon' | |
task :restart => [:stop, :start] | |
end |
Thanks for the gist!
Glad it was useful for you. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I really feel like this should come with clockwork.rb somehow.