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
reporting?
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
> end
>
> def other_method
> logger.info(''other_method in ExampleWorker called'')
> results[:extra_data] = "Just a plain old string"
> end
>
> end
> ExampleWorker.register
>
> Then in a controller, I have:
>
> def test_backgroundrb
> key = MiddleMan.new_worker(:class => :example_worker)
> worker = MiddleMan.worker(key)
> worker.other_method
> worker.delete
> end
>
> When I point the browser to test_backgroundrb, I get:
>
> NoMethodError (undefined method `object'' for nil:NilClass):
> (drbunix:///tmp/backgroundrbunix_localhost_2000)
>
/home/wil/proj/3cgworkspace/thoughtless/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:396:in
> `worker''
> 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''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.0/lib/action_controller/base.rb:1095:in
> `perform_action_without_filters''
> 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.
>
> Wil
>
--
http://www.3cglabs.com
http://thoughtl.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070526/5c1d119a/attachment.html