Hello Mathias,
sorry for the late reply.
Please do
---8<---
require "rufus/scheduler"
s = Rufus::Scheduler.start_new
j = s.cron("* * * * *") do
puts "*** Executing #{Time.now}"
end
s.join
--->8---
so that the Ruby runtime doesn't exit (let it join the scheduler thread).
Best regards,
--
John Mettraux - http://jmettraux.wordpress.com
Hello Mathias,
Yes, you are right, the join is not necessary in those two cases. Well, rufus-scheduler will be "alive" as long at the Ruby process behind irb or Rails is running.
> Because if I
> join the main thread in my Rails app it will obviously block forever
> on the scheduler. Or do I have to fork an extra thread myself for the
> scheduler? Seems I have a conceptual misunderstanding here on how
> Rufus works...
The scheduler will use 1 thread for its work. Starting the scheduler creates that thread.
You don't have to "join" as long as the HTTP request handling loop is alive and prevents the Ruby process from terminating.
There is no magic.
Of course, it's useless to have to call #join when in irb.
Try the following experiment in your irb :
> Thread.new { sleep 1; puts "nada" }
And then wait two seconds, then do :
> puts "ok"
...
> Same in Rails...
Probably not linked to the "issue" you're seeing in irb.
What web server are you running Rails with ? Webrick, Thin, Passenger ?
Hello,
yes it should work. I had never tried from irb.
https://github.com/jmettraux/rufus-scheduler/issues/22
Thanks for the feedback, best regards,
Hello Mathias,
"believing" is for the church or whatever worship bikeshed you go to (don't tell me you're a Jedi Knight, I don't want to know).
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
Since 2007, I've helped various people integrate rufus-scheduler within their rails application, so "it does not work in Rails either", I don't believe it either.
I'm OK with it not working in IRB, since not many people schedule stuff from IRB, manually, so it might have gone unnoticed all this time, but not for the Rails issue you believe in.
Best regards,
I am sure John can fend for himself but I have to support John on this. Given the level of (free!) support he gives you should be ashamed of yourself. Please take your disrespect elsewhere....
Regards,
Klaas Jan Wierenga
> --
> 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
Hello Klaas,
thanks for the support and the help. Much appreciated !
Hello Mathias,
rufus-scheduler is a project, not a product.
The reaction you have provoked is simply exasperation. As already written, I've read here about people using this scheduler here and there, and suddenly you claim and come it doesn't work with Rails.
It took four days of this thread to extract the first issue report (the one about irb).
The one about "rails and thin" is more important it seems, but it's hidden behind a "belief". I got tired, I didn't want to spend another 4 days trying to extract information out of you. You seem to be sitting right in front of the issue, could you please describe it for me in details ? It would save us both time.
If you don't have the time anymore, I'd suggest you look at a similar library, it's called "clockwork":
https://github.com/adamwiggins/clockwork
I can't say anything about this library's level of maturity. The author is a very talented guy, that I know for sure.
Sorry for my loss of temper, best regards,