[Backgroundrb-devel] First call to worker method doesn't work

Dylan Markow dmarkow at gmail.com
Fri Apr 4 01:12:36 EDT 2008


On Thu, Apr 3, 2008 at 8:57 PM, Dylan Markow <dmarkow at gmail.com> wrote:
> I have a worker as follows:
>
>  class SampleWorker < BackgrounDRb::MetaWorker
>   set_worker_name :sample_worker
>   def create(args = nil)
>     # this method is called, when worker is loaded for the first time
>   end
>
>   def my_method
>     # Deliver test e-mail message
>     Notifications.deliver_message(1, "DM")
>   end
>  end
>
>  I have a rails controller that calls the following code:
>
>     worker = MiddleMan.worker(:sample_worker)
>     worker.my_method
>
>  The problem is that the first time I load up the page for this action,
>  the worker method "my_method" doesn't seem to ever get called. There
>  is zero output from any of the backgroundrb log files. If I then
>  reload the page, it works fine (and continues to work fine until
>  backgroundrb is restarted).
>
>  This happens whether I'm in dev. or prod. mode.
>

To clarify, if I restart rails AND backgroundrb at the same time,
everything works fine. it's only if backgroundrb needs to restart on
its own for some reason. It looks like when the backgroundrb process
is restarted, rails doesn't realize this as it still sees port 11006
open. So my first request to the page results in the rails plugin
attempting to write data to the socket. I'm assuming this screws
something up, as upon the second attempt at loading my page, "rescue
Errno::EPIPE" at line 64 of backgroundrb.rb is called, thus
re-establishing the connection. I'm assuming this problem may be more
closely related to the packet gem? (Not sure if there is a trac repo
for packet).


More information about the Backgroundrb-devel mailing list