[Backgroundrb-devel] cron scheduling problem

Meng Kuan mengkuan at gmail.com
Thu Jan 31 12:02:23 EST 2008


On 01 Feb 2008, at 12:48 AM, Tom Wood wrote:

> I’m running a fresh checkout of release 1.0.1 …
>
>
>
> It’s now 11:32 am local time on January 31.
>
>
>
> I’ve configured a single worker for a test.
>
>
>
> If I use the following schedule in my background.yaml file:
>
>
>
> :schedules:
>
>   :debugger_worker:
>
>     :ping:
>
>       :trigger_args: 0 35 11 * * * *
>
>
>
> Backgroundrb starts up without error.
>
>
>
> If I make the following change:
>
>
>
>       :trigger_args: 0 30 11 * * * *
>
>
>
> Backgroundrb complains:
>
>
>
> brb-test/vendor/plugins/backgroundrb/server/cron_trigger.rb:161:in  
> `local': argument out of range (ArgumentError)
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> cron_trigger.rb:161:in `fire_time_after'
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> meta_worker.rb:266:in `new_load_schedule'
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> meta_worker.rb:258:in `each'
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> meta_worker.rb:258:in `new_load_schedule'
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> meta_worker.rb:183:in `worker_init'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> worker.rb:20:in `start_worker'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> packet_master.rb:134:in `fork_and_load'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> packet_master.rb:98:in `load_workers'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> packet_master.rb:93:in `each'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> packet_master.rb:93:in `load_workers'
>
>         from brb-test/vendor/plugins/backgroundrb/framework/ 
> packet_master.rb:19:in `run'
>
>         from brb-test/vendor/plugins/backgroundrb/server/ 
> master_worker.rb:163:in `initialize'
>
>         from script/backgroundrb:60:in `new'
>
>         from script/backgroundrb:60
>
>
>
> A puts added to cron_trigger.rb reveals why Time.local is failing.   
> When the worker is scheduled to run at 11:35, Time.local is called  
> ala:
>
>
>
> Calling Time.local 0, 35, 11, 31, 1, 2008, 4, 31, false, EST
>
>
>
> When the worker is scheduled to run at 11:30, Time.local fails and  
> is called:
>
>
>
> Calling Time.local 0, 30, 11, 32, 1, 2008, 4, 31, false, EST
>
>
>
> “32” is not a valid day of the month.
>
>
>
> I think the error is dependent on the time that backgroundrb  
> starts.  When I waited until 11:40, backgroundrb started to  
> generate the same exception for the 11:35 worker.
>
>
>

Hi Tom,

The following is from an email I sent to the list earlier today. You  
can give it a try:

It appears that cron_trigger incremented the day value beyond the  
number of days of the current month (from 31 to 32) and this caused  
the Time.local call to abort.

Here's my patch to adjust for this.

$ diff -c3 cron_trigger.rb cron_trigger.rb.new
*** cron_trigger.rb     Thu Dec 20 17:27:47 2007
--- cron_trigger.rb.new Thu Jan 31 14:25:57 2008
***************
*** 126,131 ****
--- 126,135 ----
             if next_hour < hour
               hour = next_hour
               day += 1
+             if day > month_days(year, month)
+               day -= month_days(year, month)
+               month += 1
+             end
               retry
             end
             hour = next_hour





More information about the Backgroundrb-devel mailing list