[Backgroundrb-devel] 1.0.3 problems with script/start

Alex Peuchert rubyonrails-ug at peuchert.de
Mon Mar 3 17:42:45 EST 2008


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


More information about the Backgroundrb-devel mailing list