jmettraux/rufus-scheduler

Scheduler not Running - Passenger + Nginx

codyrickmanvessel opened this issue · 6 comments

Hello, I have seen a lot of older threads on this but none of the solutions have worked for me. I am having the classic issue of the scheduler not running when deployed to production with Nginx and Passenger.

System:

CentOS 7
rails 5.1.6
ruby 2.5.3
rufus-scheduler 3.6.0

passenger.conf

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;
passenger_spawn_method direct;
passenger_min_instances 1;
passenger_pool_idle_time 0;

app.conf

server {
    listen 3000;
    server_name localhost;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /home/user/app/public;

    # Turn on Passenger
    passenger_enabled on;
    passenger_ruby /usr/local/rvm/gems/ruby-2.5.3/wrappers/ruby;
}

sheduler.rb

require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new

scheduler.every '1h' do
  //Some Task
end

Is there something I am missing of another passenger parameter I need to try? Thank You.

Sorry, did you find any help in the Passenger forum?

Could you please indicate what version of Passenger and what version of Nginx you're using (update your question text).

I am reading the Passenger documentation right now so I need to know.

Have you tried passenger_pre_start to make sure Passenger does not sit idle while waiting the first request?

No answer. Closing.

Hi, I thought I was having a problem with rails + passenger + nginx, so I googled everywhere for a solution and found this issue. Though it turns out it was just misconfiguration on my part (I think) since the jobs are executing now.

I'm not really sure if rufus-scheduler works out of the box with rails + passenger + nginx now, since the stackoverflow questions seem to be a few years old now. In any case my scheduled jobs work fine (some every 4 hours, some daily), without configuring nginx/passenger. I'll continue to observe if the scheduler works as expected.

In any case I'll just leave this here in case something goes wrong:
https://stackoverflow.com/a/28062602

rails_app_spawner_idle_time 0;
passenger_min_instances 1;

https://stackoverflow.com/a/36791451

passenger_spawn_method direct;
passenger_min_instances 1;
passenger_pool_idle_time 0;

My setup for reference:
Operating System: Ubuntu 18 LTS
Phusion Passenger 6.0.2
nginx version: nginx/1.14.0
rails (4.2.6)
rufus-scheduler (3.6.0)

Thanks for sharing!