# BackgrounDRb

**URL:** <https://www.ruby-forum.com/t/backgroundrb/141381>\
**Category:** Rails\
**Created:** [June 25, 2008, 8:42am UTC](https://www.ruby-forum.com/t/backgroundrb/141381 "2008-06-25T08:42:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 25, 2008, 8:42am UTC](https://www.ruby-forum.com/t/backgroundrb/141381/1 "2008-06-25T08:42:46Z")

</div>

I have installed the latest backgrouDrb plugin in my rails application.  
I have scheduled a task in the backgroundrb.yml, but nothing seems to  
happen, when i start the backgroundrb server. I am running Mac OS X  
10.5.2. I see no errors or anything. Logs shows that the workers class  
is started, but then worker method is never invoked as scheduled.

Here is my backgroundrb.yml file:  
:backgroundrb:  
:ip: 0.0.0.0  
:port: 11006

:schedules:  
:appointment\_mailer:  
:nightly\_mails:  
:trigger\_args:  
:start: \<%= Time.now + 5.seconds %\>  
🔚 \<%= Time.now + 10.minutes %\>  
:repeat\_interval: \<%= 1.minute %\>

And the worker class is:  
class AppointmentMailerWorker \< BackgrounDRb::MetaWorker  
set\_worker\_name :appointment\_mailer\_worker  
def create(args = nil)  
# this method is called, when worker is loaded for the first time  
end

def nightly\_mails()  
logger.info “HELOO WORLD”  
end

end

Please help me to know what the problem could be.

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 25, 2008, 10:26am UTC](https://www.ruby-forum.com/t/backgroundrb/141381/2 "2008-06-25T10:26:41Z")

</div>

You missed the \_worker part of the worker name in the schedule.

set\_worker\_name :appointment\_mailer\_worker

So you need this:  
:schedules:  
:appointment\_mailer\_worker:  
:nightly\_mails:  
…

On 25 Jun., 08:42, Dipesh B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 25, 2008, 2:14pm UTC](https://www.ruby-forum.com/t/backgroundrb/141381/3 "2008-06-25T14:14:32Z")

</div>

That doesn’t helped either. I added some logging in create method of the  
worker class. While starting, backgroundrb, i can see the effect in the  
drb’s log file. But that schedule thing doesn’t seem to work. Does  
anybody have some tested steps to make a schedule work. Can there be  
some issue with Mac OS 10.5 ?

Sebastian Staudt wrote:

> You missed the \_worker part of the worker name in the schedule.
> 
> set\_worker\_name :appointment\_mailer\_worker
> 
> So you need this:  
> :schedules:  
> :appointment\_mailer\_worker:  
> :nightly\_mails:  
> …
> 
> On 25 Jun., 08:42, Dipesh B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 25, 2008, 7:42pm UTC](https://www.ruby-forum.com/t/backgroundrb/141381/4 "2008-06-25T19:42:44Z")

</div>

On Wed, Jun 25, 2008 at 5:44 PM, Dipesh B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> That doesn’t helped either. I added some logging in create method of the  
> worker class. While starting, backgroundrb, i can see the effect in the  
> drb’s log file. But that schedule thing doesn’t seem to work. Does  
> anybody have some tested steps to make a schedule work. Can there be  
> some issue with Mac OS 10.5 ?

Get the latest version from Git as outlined in  
[backgroundrb.rubyforge.org](http://backgroundrb.rubyforge.org). Also, is your create method returning, or  
is it stuck somewhere? Can i see your actual worker code that you are  
running? If create method is working, then you could have messed with  
config file or create method is not returning at all. Either ways,  
paste your actual worker code.

Also, use pastie or something to paste code since, gmail screws up  
code formatting.

–  
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](http://gnufied.org)

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 26, 2008, 8:09pm UTC](https://www.ruby-forum.com/t/backgroundrb/141381/5 "2008-06-26T20:09:46Z")

</div>

By the way, i installed it as a plugin in Rails, rather then as a gem.  
Could that cause some issue?

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 26, 2008, 7:44pm UTC](https://www.ruby-forum.com/t/backgroundrb/141381/6 "2008-06-26T19:44:59Z")

</div>

Well, I dergaded back to the version 1.01. Now my worker runs if i  
hard code the schedule in backgroundrb.yml . But it does nothing if a  
create new worker in the Rails controller with same schedule.  
Here is action which i run to invoke the worker:

def appointments\_summery  
MiddleMan.new\_worker(:worker  
=\> :appointment\_reminder\_worker, :job\_key =\> :hello\_world, :data =\>  
“wow\_man”, :schedule =\> { :appointments\_summery =\> { :trigger\_args =\>  
“\*/5 \* \* \* \* \* \*”,:data =\> “hello\_world” }})  
render :text =\> “worker starterd”  
end

Worker code is pretty simple, it just logs some text:  
def appointments\_summery(args = nil)  
logger.info “HELLOOWOWO: #{args}”  
end

Everything other method to start workers, are working fine, through  
backgroundrb.yml, MiddleMan.send\_request, MiddleMan.ask\_work. Only the  
MiddleMan.new\_worker doesn’t respond.

I will try to get the latest release from GIT and see if it works. By  
the way, there is “—” right at the top of autogenerated  
backgroundrb.yml. Is that important?

Thanks for the help

---

<div class="post-metadata">

**Author:** ![dipeshbatheja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dipeshbatheja](https://www.ruby-forum.com/u/dipeshbatheja)\
**Post date:** [June 26, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/backgroundrb/141381/7 "2008-06-26T21:16:39Z")

</div>

I checked the status of my the worker i created using worker\_info  
function. Its shows status as stopped. Do i need to explicitly do  
something after i start a new worker using MiddleMan.new\_worker.
