Where does the entry point script go?

66 views
Skip to first unread message

Patrick Stinson

unread,
Mar 3, 2014, 10:35:35 PM3/3/14
to rufus...@googlegroups.com
Hi there, what's the proper way to kick off a rufus thread?

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? 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)?

Thanks so much!

John Mettraux

unread,
Mar 4, 2014, 12:16:22 AM3/4/14
to rufus...@googlegroups.com

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?

Hello Patrick,

well, you simply kick off a rufus thread by instantiating the scheduler.

```ruby
require 'rufus-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
( https://github.com/jmettraux/rufus-scheduler/ )
Here is the link:
http://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555

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...


Best regards,

John

Patrick Stinson

unread,
Mar 4, 2014, 12:27:52 AM3/4/14
to rufus...@googlegroups.com
Read, read, and read. Too bad we have to use direct spawning with rufus since it’s slower, but it makes sense why.

Thanks for the support.

Patrick Stinson
Owner, Software & Interactivity Expert

--
--
you received this message because you are subscribed to the "rufus ruby" group.
to post : send email to rufus...@googlegroups.com
to unsubscribe : send email to rufus-ruby+...@googlegroups.com
more options : http://groups.google.com/group/rufus-ruby?hl=en
---
You received this message because you are subscribed to the Google Groups "Rufus Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rufus-ruby+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

John Mettraux

unread,
Mar 4, 2014, 12:46:16 AM3/4/14
to rufus...@googlegroups.com
2014-03-04 14:27 GMT+09:00 Patrick Stinson <pat...@vedanamedia.com>:
> Read, read, and read. Too bad we have to use direct spawning with rufus
> since it's slower, but it makes sense why.

I do not use Passenger, but I remember that there were other options
than "direct spawning". As long as the initial rufus-scheduler thread
is preserved, it's OK, direct spawning or indirect whatevering
included. Don't close doors, run tests, do try.

Cheers,

John
Reply all
Reply to author
Forward
0 new messages