Hi. just updated to 1.0.3, and am having problems starting bdrb. It seems to be confused about my backgroundrb.yml file. I''m trying to schedule recurring tasks from the yml file, it looks like this: -------------------------------------------------------------------------------------------------- :backgroundrb: :ip: localhost :port: 11006 :environment: development :log: foreground :schedules: :app_task_worker: :clean_sessions: :trigger_args: :start: <%= Time.now + 5.seconds %> :end: <%= Time.now + 2.years %> :repeat_interval: <%= 1.day %> -------------------------------------------------------------------------------------------------- here is some cmdline output: ctro$ script/backgroundrb --version 1.0.3 ctro$ script/backgroundrb start (erb):11: undefined method `seconds'' for 5:Fixnum (NoMethodError) --------------------------------------------------------------------------------------------------- Is this not the correct way to schedule the worker? Also, a slightly related question: how does the add_periodic_timer method work? Is it started up "automatically" like workers used to be in the example above? Thanks again! -clint
Ryan Leavengood
2008-Mar-03 17:28 UTC
[Backgroundrb-devel] 1.0.3 problems with script/start
On Mon, Mar 3, 2008 at 12:08 PM, Clint Troxel <clint at ctro.net> wrote:> ctro$ script/backgroundrb start > (erb):11: undefined method `seconds'' for 5:Fixnum (NoMethodError) > > --------------------------------------------------------------------------------------------------- > > Is this not the correct way to schedule the worker?You are getting that error because the 5.seconds and 2.years methods are not by default in Ruby, they are added by classes in Rails. It seems the Rails code and environment is not loaded at the time the backgroundrb.yml file is loaded. Since the above syntax is shown on the BackgrounDRb documentation, I can only assume this is a bug. The simple solution for the time being is to just "expand" those values using the Rails console: Loading development environment.>> 5.seconds=> 5>> 2.years=> 63115200>> 1.day=> 86400 Then use those expanded values in the backgroundrb.yml file.> Also, a slightly related question: how does the add_periodic_timer > method work? Is it started up "automatically" like workers used to be > in the example above?If you put a call to add_periodic_timer in your create method for workers loaded automatically (which is all workers by default), then yes the periodic timer will be set up automatically. Regards, Ryan
Ryan Leavengood wrote:> On Mon, Mar 3, 2008 at 12:08 PM, Clint Troxel <clint at ctro.net> wrote: > >> ctro$ script/backgroundrb start >> (erb):11: undefined method `seconds'' for 5:Fixnum (NoMethodError) >> >> --------------------------------------------------------------------------------------------------- >> >> Is this not the correct way to schedule the worker? >> > > You are getting that error because the 5.seconds and 2.years methods > are not by default in Ruby, they are added by classes in Rails. It > seems the Rails code and environment is not loaded at the time the > backgroundrb.yml file is loaded. > > Since the above syntax is shown on the BackgrounDRb documentation, I > can only assume this is a bug. > > The simple solution for the time being is to just "expand" those > values using the Rails console: > > Loading development environment. > >>> 5.seconds >>> > => 5 > >>> 2.years >>> > => 63115200 > >>> 1.day >>> > => 86400 > > Then use those expanded values in the backgroundrb.yml file. > > >> Also, a slightly related question: how does the add_periodic_timer >> method work? Is it started up "automatically" like workers used to be >> in the example above? >> > > If you put a call to add_periodic_timer in your create method for > workers loaded automatically (which is all workers by default), then > yes the periodic timer will be set up automatically. > > Regards, > Ryan > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > >Hi! Thanks for the pointing this out. I changed the loading of the RoR framewok in script/backgroundrb: - parse CLI parameters - load RoR - load config/backgroundrb.yml submitted that to Gitorious repo as commit 78b956b -Alex