collectiveidea / delayed_job

Database based asynchronous priority queue system -- Extracted from Shopify
http://groups.google.com/group/delayed_job
MIT License
4.81k stars 955 forks source link

Delayed job daemon forcefully closes all udp file descriptors under port 8192 #960

Closed guyisra closed 1 month ago

guyisra commented 7 years ago

In my rails app I am using statsd to report metrics. The reporting works in any model/controller that runs in the main rails process. The reporting also works when using the work_off rake task.

When using the delayed job as a daemon it does not work. It seems that the Daemon gems closes off all udp file descriptors (in port 1 to 8192) when the worker thread is being created.

This means a lot of things will not work out of the box, like statsd.

Is there a way around this (other than reconnecting for every job)?

betamatt commented 7 years ago

You don't need to reconnect for each job, you just need to reconnect after the worker forks. There isn't a lifecycle hook exposed for this so currently the only way to do it is to monkey patch Delayed::Worker.after_fork (in the alias_method_chain style) and append your own behavior.

On Sat, Dec 17, 2016 at 8:59 AM Guy notifications@github.com wrote:

In my rails app I am using statsd to report metrics. The reporting works in any model/controller that runs in the main rails process. The reporting also works when using the work_off rake task.

When using the delayed job as a daemon it does not work. It seems that the Daemon gems closes off all udp file descriptors when the worker thread is being created.

Is there a way around this (other than reconnecting for every job)?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/collectiveidea/delayed_job/issues/960, or mute the thread https://github.com/notifications/unsubscribe-auth/AABZ-NT6JgCBclPgTRPCrEb0wE_2fRv8ks5rI-rXgaJpZM4LP5Kq .

DannyBen commented 6 years ago

I think I may be experiencing a very related issue:

When trying to change the logger for DelayedJob, to a logger that uses UDP, I am getting an error saying RemoteSyslogLogger::UdpSender error: IOError: closed stream.

Could this be related? If so, any word as to how to overcome this?

This is the related StackOverflow question if it is of any interest.

albus522 commented 1 month ago

Closing stale