# BackgrounDRb behavoir

**URL:** <https://www.ruby-forum.com/t/backgroundrb-behavoir/105196>\
**Category:** Ruby\
**Created:** [May 27, 2007, 1:58am UTC](https://www.ruby-forum.com/t/backgroundrb-behavoir/105196 "2007-05-27T01:58:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yeago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yeago](https://www.ruby-forum.com/u/yeago)\
**Post date:** [May 27, 2007, 1:58am UTC](https://www.ruby-forum.com/t/backgroundrb-behavoir/105196/1 "2007-05-27T01:58:56Z")

</div>

Call me confused. I call the following:

MiddleMan.schedule\_worker(  
:class =\> :update\_friends\_worker,  
:job\_key =\> :schedule\_test,  
:worker\_method =\> :arg\_method,  
:worker\_method\_args =\> “my argument to arg\_method”,  
:trigger\_type =\> :cron\_trigger,  
:trigger\_args =\> “1 \* \* \* \* \* \*”  
)

And that worker looks like:

class UpdateFriendsWorker \< BackgrounDRb::Worker::RailsBase

def do\_work(args)  
logger.info(‘Shoes’)  
end

end  
UpdateFriendsWorker.register

Shouldn’t the above put an entry ‘Shoes’ in the log every minute? I only  
get 1, and that’s it. Been waiting 5 minutes.

-Steve

---

<div class="post-metadata">

**Author:** ![yeago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yeago](https://www.ruby-forum.com/u/yeago)\
**Post date:** [May 27, 2007, 2:22am UTC](https://www.ruby-forum.com/t/backgroundrb-behavoir/105196/2 "2007-05-27T02:22:05Z")

</div>

On May 26, 2007, at 4:59 PM, Sy Ys wrote:

> Call me confused. I call the following:
> 
> MiddleMan.schedule\_worker(  
> :class =\> :update\_friends\_worker,  
> :job\_key =\> :schedule\_test,  
> :worker\_method =\> :arg\_method,

```
                                       ^^^^^^^^^^

```

The method that will be called by the scheduler is :arg\_method since  
thats how you defined it. The do\_work method always gets called once  
on worker instantiation. the :worker\_method is the method that will  
be called by the scheduler.

> ```
> logger.info('Shoes')
> 
> ```
> 
> end

```
 def arg_method
     logger.info('UrMom')
 end

```

> end  
> UpdateFriendsWorker.register
> 
> Shouldn’t the above put an entry ‘Shoes’ in the log every minute? I  
> only  
> get 1, and that’s it. Been waiting 5 minutes.
> 
> -Steve

Cheers-  
– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![yeago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yeago](https://www.ruby-forum.com/u/yeago)\
**Post date:** [May 27, 2007, 3:51pm UTC](https://www.ruby-forum.com/t/backgroundrb-behavoir/105196/3 "2007-05-27T15:51:37Z")

</div>

Doh. Simple mistake.

One more question. What is the preferred method for granting workers in  
/lib/workers access to my application’s controller classes?

Ezra Z. wrote:

> The method that will be called by the scheduler is :arg\_method since  
> thats how you defined it. The do\_work method always gets called once  
> on worker instantiation. the :worker\_method is the method that will  
> be called by the scheduler.
