Hi, I was trying to schedule a worker to run during the midnight hour like this: :schedules: :collector: :process_something: :trigger_args: 30 * 0 * * 2,3,4,5,6 When I try to start backgroundrb, the "collector" worker failed to start up and I find this in backgroundrb_server.log: /home/mengkuan/apps/testrailsapp/current/vendor/plugins/backgroundrb/ server/cron_trigger.rb:160:in `local'': argument out o f range (ArgumentError) from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/cron_trigger.rb:160:in `fire_time _after'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:266:in `new_load_s chedule'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:258:in `each'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:258:in `new_load_s chedule'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:183:in `worker_ini t'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/worker.rb:20:in `start_ worker'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:139:in `fork_and_load'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:98:in `load_workers'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:93:in `each'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:93:in `load_workers'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:19:in `run'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/master_worker.rb:163:in `initiali ze'' from script/backgroundrb:41:in `new'' from script/backgroundrb:41 However, if I modify the trigger_args line like the following, the worker runs fine: :schedules: :collector: :process_something: :trigger_args: 30 * 0,1 * * 2,3,4,5,6 cheers, mengkuan
I wonder if its because you need 7 entries for trigger_args?>From the docs:The fields (which can be an asterisk, meaning all valid patterns) are: sec[0,59] min[0,59], hour[0,23], day[1,31], month[1,12], weekday[0,6], year Looks like you''re missing "year". Of course, that may not be right since your second example works... Scotty -----Original Message----- From: backgroundrb-devel-bounces at rubyforge.org [mailto:backgroundrb-devel-bounces at rubyforge.org] On Behalf Of Meng Kuan Sent: Wednesday, January 30, 2008 9:59 AM To: backgroundrb-devel at rubyforge.org Subject: [Backgroundrb-devel] Schedule parser Hi, I was trying to schedule a worker to run during the midnight hour like this: :schedules: :collector: :process_something: :trigger_args: 30 * 0 * * 2,3,4,5,6 When I try to start backgroundrb, the "collector" worker failed to start up and I find this in backgroundrb_server.log: /home/mengkuan/apps/testrailsapp/current/vendor/plugins/backgroundrb/ server/cron_trigger.rb:160:in `local'': argument out o f range (ArgumentError) from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/cron_trigger.rb:160:in `fire_time _after'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:266:in `new_load_s chedule'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:258:in `each'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:258:in `new_load_s chedule'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/meta_worker.rb:183:in `worker_ini t'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/worker.rb:20:in `start_ worker'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:139:in `fork_and_load'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:98:in `load_workers'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:93:in `each'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:93:in `load_workers'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/framework/packet/packet_master.rb:19:in `run'' from /home/mengkuan/apps/testrailsapp/current/vendor/plugins/ backgroundrb/server/master_worker.rb:163:in `initiali ze'' from script/backgroundrb:41:in `new'' from script/backgroundrb:41 However, if I modify the trigger_args line like the following, the worker runs fine: :schedules: :collector: :process_something: :trigger_args: 30 * 0,1 * * 2,3,4,5,6 cheers, mengkuan _______________________________________________ Backgroundrb-devel mailing list Backgroundrb-devel at rubyforge.org http://rubyforge.org/mailman/listinfo/backgroundrb-devel
On 31 Jan 2008, at 2:12 AM, Scott Ward wrote:> I wonder if its because you need 7 entries for trigger_args? > >> From the docs: > > The fields (which can be an asterisk, meaning all valid patterns) are: > sec[0,59] min[0,59], hour[0,23], day[1,31], month[1,12], weekday > [0,6], > year > > Looks like you''re missing "year". Of course, that may not be right > since > your second example works... >I just added a ''*'' to the end for the ''year'' argument as you mentioned but same results. The year argument is probably optional. Btw, the trigger_args that actually worked for me is :trigger_args: 30 * 0,1,2 * * 2,3,4,5,6 This one that I posted in my first mail gave the same errors: :trigger_args: 30 * 0,1 * * 2,3,4,5,6
On 31 Jan 2008, at 2:19 AM, Meng Kuan wrote:> > On 31 Jan 2008, at 2:12 AM, Scott Ward wrote: > >> I wonder if its because you need 7 entries for trigger_args? >> >>> From the docs: >> >> The fields (which can be an asterisk, meaning all valid patterns) >> are: >> sec[0,59] min[0,59], hour[0,23], day[1,31], month[1,12], >> weekday[0,6], >> year >> >> Looks like you''re missing "year". Of course, that may not be >> right since >> your second example works... >> > > I just added a ''*'' to the end for the ''year'' argument as you > mentioned but same results. The year argument is probably optional. > > > Btw, the trigger_args that actually worked for me is > > :trigger_args: 30 * 0,1,2 * * 2,3,4,5,6 > > > This one that I posted in my first mail gave the same errors: > > :trigger_args: 30 * 0,1 * * 2,3,4,5,6The above still did not solve the problem. So I dug deeper and found a possible logic bug in cron_trigger.rb file. 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 This seems to finally fix the problem for me. cheers, mengkuan
On Thu, Jan 31, 2008 at 12:04 PM, Meng Kuan <mengkuan at gmail.com> wrote:> > On 31 Jan 2008, at 2:19 AM, Meng Kuan wrote: > > > > > On 31 Jan 2008, at 2:12 AM, Scott Ward wrote: > > > >> I wonder if its because you need 7 entries for trigger_args? > >> > >>> From the docs: > >> > >> The fields (which can be an asterisk, meaning all valid patterns) > >> are: > >> sec[0,59] min[0,59], hour[0,23], day[1,31], month[1,12], > >> weekday[0,6], > >> year > >> > >> Looks like you''re missing "year". Of course, that may not be > >> right since > >> your second example works... > >> > > > > I just added a ''*'' to the end for the ''year'' argument as you > > mentioned but same results. The year argument is probably optional. > > > > > > Btw, the trigger_args that actually worked for me is > > > > :trigger_args: 30 * 0,1,2 * * 2,3,4,5,6 > > > > > > This one that I posted in my first mail gave the same errors: > > > > :trigger_args: 30 * 0,1 * * 2,3,4,5,6 > > > The above still did not solve the problem. So I dug deeper and found > a possible logic bug in cron_trigger.rb file. 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 > > > This seems to finally fix the problem for me.Thanks Meng, We will have this patch in. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
On 01 Feb 2008, at 1:28 AM, hemant wrote:>> The above still did not solve the problem. So I dug deeper and found >> a possible logic bug in cron_trigger.rb file. 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 >> >> >> This seems to finally fix the problem for me. > > Thanks Meng, We will have this patch in. >Found another bug in cron_trigger. When I specify the hour as a range like "8-17", the parse_part method returns an empty array. This is because Range.new handles string arguments and integer arguments differently. Compare irb(main):001:0> Range.new("8","17") => "8".."17" irb(main):002:0> Range.new("8","17").to_a => [] to this: irb(main):003:0> Range.new(8, 17).to_a => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17] The fix is to convert the argument to integer first before handing it to Range.new. See the following patch. $ diff -u cron_trigger.rb cron_trigger.rb.new --- cron_trigger.rb 2007-12-20 17:27:47.000000000 +0800 +++ cron_trigger.rb.new 2008-02-04 16:04:53.000000000 +0800 @@ -215,7 +215,7 @@ r = Array.new part.split('','').each do |p| if p =~ /-/ # 0-5 - r << Range.new(*p.scan(/\d+/)).to_a.map do |x| x.to_i end + r << Range.new(*p.scan(/\d+/).map {|x| x.to_i}).to_a elsif p =~ /(\*|\d+)\/(\d+)/ and not range.nil? # */5, 2/10 min = $1 == ''*'' ? 0 : $1.to_i inc = $2.to_i
On Feb 4, 2008 1:43 PM, Meng Kuan <mengkuan at gmail.com> wrote:> > > On 01 Feb 2008, at 1:28 AM, hemant wrote: > > >> The above still did not solve the problem. So I dug deeper and found > >> a possible logic bug in cron_trigger.rb file. 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 > >> > >> > >> This seems to finally fix the problem for me. > > > > Thanks Meng, We will have this patch in. > > > > > Found another bug in cron_trigger. When I specify the hour as a range > like "8-17", the parse_part method returns an empty array. This is > because Range.new handles string arguments and integer arguments > differently. Compare > > irb(main):001:0> Range.new("8","17") > => "8".."17" > irb(main):002:0> Range.new("8","17").to_a > => [] > > to this: > > irb(main):003:0> Range.new(8, 17).to_a > => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17] > > > The fix is to convert the argument to integer first before handing it > to Range.new. See the following patch. > > > $ diff -u cron_trigger.rb cron_trigger.rb.new > --- cron_trigger.rb 2007-12-20 17:27:47.000000000 +0800 > +++ cron_trigger.rb.new 2008-02-04 16:04:53.000000000 +0800 > @@ -215,7 +215,7 @@ > r = Array.new > part.split('','').each do |p| > if p =~ /-/ # 0-5 > - r << Range.new(*p.scan(/\d+/)).to_a.map do |x| x.to_i end > + r << Range.new(*p.scan(/\d+/).map {|x| x.to_i}).to_a > elsif p =~ /(\*|\d+)\/(\d+)/ and not range.nil? # */5, 2/10 > min = $1 == ''*'' ? 0 : $1.to_i > inc = $2.to_i >Send me your Devjavu and Rubyforge account logins, I will add you as a developer, so that you can have commit access.