Created
December 7, 2010 07:18
-
-
Save nileshbetter/731553 to your computer and use it in GitHub Desktop.
Dynamic Schedule Assignment doesn't work
This file contains hidden or 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
Following schedule is set on Intialization. config/initializers | |
jt = ATask.find(:first) | |
dmt = BTask.find(:first) | |
Resque.schedule = {"ASchedule" => { | |
"cron" => "0 */#{jt.hours} * * *", | |
"class" => A, | |
"args" => "", | |
"description" => "Job for A" | |
}, | |
"BSchedule" => { | |
"cron" => "#{dmt.run_at_mins} #{dmt.run_at_hrs} * * *", | |
"class" => B, | |
"args" => "", | |
"description" => "Job for B" | |
} | |
} | |
Above is a default schedule. Admin may want to change/update it. An interface is provided to Admin to do that. When Admin does the Schedule update, I execute following code in m controller | |
@b.run_at_hrs = params["hrs"].to_i | |
@b.run_at_mins = params["mns"].to_i | |
@b.save | |
Resque.schedule = { | |
"ASchedule" => { | |
"cron" => "0 */#{@task.hours} * * *", | |
"class" => A, | |
"args" => "", | |
"description" => "Job for A" | |
}, | |
"BSchedule" => { | |
"cron" => "#{@b.run_at_mins} #{@b.run_at_hrs} * * *", | |
"class" => B, | |
"args" => "", | |
"description" => "Job for B" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment