Reputation: 7822
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.
Upvotes: 1
Views: 3114
Reputation: 762
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;
Upvotes: 2
Reputation: 863
Add the below lines to your apache2 config and restart your apache2 server
RailsAppSpawnerIdleTime 0
PassengerMinInstances 1
Upvotes: 2