On Mon, Mar 03, 2014 at 07:35:35PM -0800, Patrick Stinson wrote:
> Hi there, what's the proper way to kick off a rufus thread?
well, you simply kick off a rufus thread by instantiating the scheduler.
scheduler = Rufus::Scheduler.new
> I see a lot of examples on how to write scripts, but where does the script
> go and how is it triggered? If I stick it in config/initializers will the
> first http request magically start a rufus process or is that even allowed?
OK, so you're talking about config/initializers/ it seems to imply you're
talking about Ruby on Rails...
No, it will not happen on the first http request. Code placed in
config/initializers/ is run when Ruby on Rails is started.
No, a rufus-scheduler process is not started. Rufus-scheduler runs in a
thread in your Ruby process.
> While I can see that running rails with WeBrick at the command line will
> keep the scheduler running until that server is shutdown, does the setup
> change when running within nginx or apache (with passenger)?
Nginx is not a "ruby" server, nor is Apache.
For Passenger, there is a link in the README
Here is the link:
Since rufus-scheduler is thread dependent, you'll have to carefully think
about where your threads (and among them the rufus-scheduler thread) go.
You'll have to make your server (webrick, thin, passenger, unicorn, ...)
preserve the rufus-scheduler thread...