[Backgroundrb-devel] New worker not being created
wil at 3cglabs.com
Sat May 26 10:51:31 EDT 2007
I figured out that in the backgroundrb.yml, I had the old setting of making
the database RAILS_ENV. It wasn't a valid variable in backgroundrb 0.2.1,
and it wasn't reporting an error, so I had no idea. Once I changed it to
'development' or 'production', it started working.
I found that if a worker has an error, it usually logs the error trace in
backgroundrb.log. However, when using a scheduled worker, it doesn't seem
to log the error stack trace at all. What's the best practice on this?
Should all methods in a worker catch exceptions and manually log the info?
Or is this something I can change/hack in backgroundrb to force error
On 5/24/07, Wil Chung <wil at 3cglabs.com> wrote:
> <backgroundrb-devel at rubyforge.org>Hi all,
> I've looked on the mailing lists and the web, and didn't find the answer,
> so I'm posting for the first time to see if I'm missing something.
> I recently upgraded to BackgroundRB 0.2.1, but I can't seem to create new
> workers now. To test things out again with a simple example, I tried
> following the example in the README of the docs.
> ./script/generate worker example
> my example worker:
> class ExampleWorker < BackgrounDRb::Worker::RailsBase
> def do_work(args)
> logger.info('ExampleWorker do work')
> results[:do_work_time] = Time.now.to_s
> results[:done_with_do_work] ||= true
> def other_method
> logger.info('other_method in ExampleWorker called')
> results[:extra_data] = "Just a plain old string"
> Then in a controller, I have:
> def test_backgroundrb
> key = MiddleMan.new_worker(:class => :example_worker)
> worker = MiddleMan.worker(key)
> When I point the browser to test_backgroundrb, I get:
> NoMethodError (undefined method `object' for nil:NilClass):
> etc. etc. etc.
> When I try to use the version from the trunk, it looks like worker returns
> nil if it doesn't find anything, as discussed per April 2007's post.
> NoMethodError (You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.other_method):
> .//app/controllers/account_controller.rb:23:in `test_backgroundrb'
> etc. etc. etc.
> What seems really odd is that while new_worker returns a key, a worker is
> never created. I verified this with a Breakpoint:
> irb(#<AccountController:0xb6bdfa04>):001:0> key = MiddleMan.new_worker(:class => :example_worker)
> => "a2dc70e7a1de822c4616113a9d602dec"
> irb(#<AccountController:0xb6bdfa04>):002:0> MiddleMan.jobs.has_key?(key)
> => false
> I don't get it. What's going on? If anyone could enlighten the matter,
> I'd greatly appreciate it. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Backgroundrb-devel