Debugging Rufus scheduler

我的未来我决定 提交于 2019-12-08 07:14:28

问题


I am doing this in my Rails console:

job = scheduler.at 1.minute.from_now do Service.log.debug 'scheduler works' end
job.schedule_info
=> Wed, 07 Aug 2013 16:14:46 UTC 00:00

scheduler is defined in other file:

require 'rubygems'
require 'rufus/scheduler'

def scheduler
  @scheduler ||= Rufus::Scheduler.start_new
end

And when I run in console:

Service.log.debug 'scheduler works'

Service log file is written.

Problem

scheduler.at 1.minute.from_now do Service.log.debug 'scheduler works' end

Does not write in the log after a minute. What am I missing? How could I debug this?

Actual problem

I have a server in EC2 that seems is shutdown and scheduled tasks are not run.

Thing is that in my development environment I test with a task running in one minute and it works. This is in server not in console. In console, as I mentioned is failing.

Dev environment

ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.0.0]

Thin 1.5.0

Remote environment

ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]

apache2 2.2.22

passenger 4.0.5

Gems

rails 3.2.8

rufus-scheduler 2.0.18


回答1:


That's a classic:

https://groups.google.com/group/rufus-ruby/search?group=rufus-ruby&q=passenger&pli=1 https://groups.google.com/forum/#!searchin/rufus-ruby/passenger (new google groups)

(unfortunately, most of the links in those discussions are dead (4 years ago...))

You'll have to check your Passenger configuration to see how it behaves. You'll have to make sure the process where the rufus-scheduler thread is started is preserved somehow.

Take the time to read the Passenger configuration / manual and experiment tuning it.

I vaguely remember that those could help:

http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerPoolIdleTime http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerMinInstances

Ajet's answer in Rufus Scheduler not running is interesting, he advocates:

RailsAppSpawnerIdleTime 0
PassengerMinInstances 1



回答2:


I had to use the "PassengerSpawnMethod direct" setting in my Apache VirtualHost for my Dashing application (which uses rufus-scheduler) to get it to work correctly.



来源:https://stackoverflow.com/questions/18108719/debugging-rufus-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!