Any way to have delayed_job execute some run-once code at startup and use across all jobs?
Posted
by Rob Cameron
on Stack Overflow
See other posts from Stack Overflow
or by Rob Cameron
Published on 2010-03-22T22:27:52Z
Indexed on
2010/03/22
22:31 UTC
Read the original article
Hit count: 268
So I've got a delayed_job task that pushes some info to an XMPP server. Ideally you create a connection to XMPP once and then constantly push data to it, rather than creating a new connection every time you have some data to send.
Is there any kind of facility in delayed_job for running a sort of 'setup' method when a worker starts, have it set some instance variables (like the XMPP connection object) that can then be used by all the jobs that come up? It's okay if each worker runs its own setup method. I just don't want every job (thousands per day) connecting to the XMPP server from scratch every time.
Thanks for any help!
© Stack Overflow or respective owner