Rufus Scheduler not running

…衆ロ難τιáo~ 提交于 2019-12-06 12:35:49

问题


I want to do something simple with the gem rufus-scheduler: https://github.com/jmettraux/rufus-scheduler

but, i can't get it to work.

I have a regular rails app. I created a .rb file:

# test_rufus_scheduler.rb
require 'rubygems'
require 'rufus/scheduler'

scheduler = Rufus::Scheduler.start_new

scheduler.in '1s' do
  puts "hello world"
end

Then, when I try ruby test_rufus_scheduler.rb, nothing happens. Am i doing it right? gem list shows rufus-scheduler.

Thanks.


回答1:


If your script exits right away please try to add

scheduler.join

at the end. Please note that it's different when running the script stand alone and via rails. See the README for detailled information.




回答2:


Found a solution to this here (which also is in sync to Ajet's answer above).

Production servers require a bit of additional setup. On most production web servers, idle Ruby processes are killed. In order for Rufus to work, you'll need to stop this from happening. For Passenger/Nginx you can copy the following code below to your nginx.conf config file for your website after the line that says passenger_enabled on;.

nginx.conf:

passenger_spawn_method direct;
passenger_min_instances 1;
passenger_pool_idle_time 0;



回答3:


Add the below lines to your apache2 config and restart your apache2 server

RailsAppSpawnerIdleTime 0
PassengerMinInstances 1


来源:https://stackoverflow.com/questions/10641122/rufus-scheduler-not-running

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