[Backgroundrb-devel] Feedback on RC2

Andy Tyra andy.tyra at gmail.com
Sat Dec 8 03:26:40 EST 2007


I'll try this over the weekend.

Found one bug.  Ironically, it occurs if you have NO schedule defined.  :)
Below is the stack trace and below that is the diff on the file that seems
to fix it.

rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:27:in
`worker_init': You have a nil object when you didn't expect it!
(NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.[]      from
rails-root/vendor/plugins/backgroundrb/framework/worker.rb:20:in
`start_worker'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:152:in
`fork_and_load'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:111:in
`load_workers'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:106:in
`each'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:106:in
`load_workers'
        from
rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:19:in
`run'
        from
rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:116:in
`initialize'
        from script/backgroundrb:25:in `new'
        from script/backgroundrb:25


svn diff meta_worker.rb
Index: meta_worker.rb
===================================================================
--- meta_worker.rb      (revision 227)
+++ meta_worker.rb      (working copy)
@@ -24,7 +24,7 @@
       @logger = PacketLogger.new(self)
       if(@worker_options[:schedule] && no_auto_load)
         load_schedule_from_args
-      elsif t_schedule = @config_file[:schedules][worker_name.to_sym]
+      elsif !@config_file[:schedules].nil? and t_schedule =
@config_file[:schedules][worker_name.to_sym]
         @my_schedule = t_schedule
         @worker_method_arity = self.method
(@my_schedule[:worker_method]).arity
         load_schedule if @my_schedule

Thx,
Andy

On Dec 7, 2007 10:50 PM, hemant kumar <gethemant at gmail.com> wrote:

>
> On Fri, 2007-12-07 at 16:09 +0530, hemant wrote:
> > On Dec 7, 2007 8:45 AM, Andy Tyra <andy.tyra at gmail.com> wrote:
> > > Sure, here is the worker code in its entirety.  For a little
> background,
> > > this is using the test framework to call a controller function which
> > > executes and renders a report.  It's done this way because the
> previous
> > > version of backgroundrb did not support accessing and calling
> controllers.
> > > (If this has changed, that would be awesome, but I'm guessing it has
> not.)
> > > That's what the extra "FakeTest" class is for.
> > >
> > > require 'active_support'
> > > require 'action_controller'
> > > require 'action_controller/test_process'
> > > require 'action_view'
> > >
> > > class ExpireAndRefreshWorker < BackgrounDRb::MetaWorker
> > >   set_worker_name :expire_and_refresh_worker
> > >   def create(args = nil)
> > >     # this method is called, when worker is loaded for the first time
> > >   end
> > >
> > >
> > >   def execute_report(report_name)
> > >         myReport = Report.new(report_name)
> > >         begin
> > >                 File.delete(File.join(RAILS_ROOT, 'public','reports',
> > > myReport.const_name + '.html'))
> > >         rescue
> > >                 #do nothing
> > >          end
> > >         renderController = FakeTest.new
> > >         renderController.render_report(myReport)
> > >         return "I am done."
> > >   end
> > >
> > >   def process_request(p_data)
> > >     user_input = p_data[:data]
> > >     result = self.send(user_input[:worker_method],user_input[:data])
> > >     send_response(p_data,result)
> > >   end
> > > end
> > >
> > > class FakeTest
> > >
> > >         include ActionController::TestProcess
> > >
> > >         def initialize
> > >                 require_dependency 'application' unless
> > > defined?(ApplicationController)
> > >                 @controller = ReportsController.new
> > >                 @request = ActionController::TestRequest.new
> > >                  @response = ActionController::TestResponse.new
> > >         end
> > >
> > >         def render_report(myReport)
> > >                 get :run, {:id => myReport.const_name}
> > >                 @response
> > >         end
> > > end
> > >
> > >
>
> Hi Andy,
>
> Sync with latest source code. The bug you encountered should be fixed
> now.
>
> And get rid of older ./script/backgroundrb file and do a setup using:
>
> rake backgroundrb:setup
>
> Also, now in configuration
> file you can mention:
>
> backgroundrb.yml:
>
> :backgroundrb:
>  :port: 11006
>  :ip: 0.0.0.0
>  :log: foreground
>
> and start backgroundrb in foreground mode using:
>
> ./script/backgroundrb
>
> this would make sure that all the exceptions appear on stdout. Give it a
> shot...
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071208/120760c8/attachment.html 


More information about the Backgroundrb-devel mailing list