BackgrounDRb

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 %>
:end: <%= 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.

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. [email protected]

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. [email protected]

On Wed, Jun 25, 2008 at 5:44 PM, Dipesh B.
[email protected] 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. 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

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

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

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.