1

I am using Rufus Scheduler to call a function once every 2 minutes.

In development mode when running rufus scheduler with WEBrick the system works as expected and my function is called every 2 minutes.

When I deploy to our production server which runs passenger and NGINX the scheduler does not call the function anymore.

I am assuming this is to do with threads, with the scheduler running on a separate thread that might be getting destroyed on our production server.

I have seen answers for similar issues when using Passenger and Apache together, but I am unable to come up with a solution for running rufus scheduler with passenger and NGINX in production mode.

Any help would be appreciated.

Code below setting up rufus

# :nocov:
require 'rufus-scheduler'
include TwitterParser
unless ENV['NODAEMON'] || Rails.env != 'production'
  scheduler = Rufus::Scheduler.new
  TwitterParser.set_up

  scheduler.every '2m' do
    begin
      TwitterParser.parse_tweets
    rescue Twitter::Error::TooManyRequests => error
      puts 'Too Many Twitter requests, resets in: ' + error.rate_limit.reset_in.to_s
    end
  end
end
# :nocov:
jmettraux
  • 3,511
  • 3
  • 31
  • 30
samb90
  • 1,063
  • 4
  • 17
  • 35

1 Answers1

0

Please read the rufus-scheduler FAQ.

https://github.com/jmettraux/rufus-scheduler#faq

It contains links to (old) articles about Passenger + rufus-scheduler

Amog them, this SO answer by one of the authors of Passenger might help:

rufus cron job not working in Apache/Passenger

Have a good time.

Community
  • 1
  • 1
jmettraux
  • 3,511
  • 3
  • 31
  • 30