rufus-scheduler: Not working on rails 4 server running on daemon mode (-d)

Tested with the simple example from the readme:

# config/initializers/scheduler.rb

require 'rufus-scheduler'

s = Rufus::Scheduler.singleton

s.every '1m' do
  Rails.logger.info "hello, it's #{Time.now}"
end

When starting the rails server with rails server -d &, rufus scheduled tasks won’t fire up.

I’ve found out that adding s.join at the end of the script fixes the issue when running as daemon, but when running just as rails server the web server won’t work, so I guess this is not intended to be used with rails.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

OK thanks for the support @jmettraux 😃

Just tried on OSX with Unicorn 4.9.0 and bundle exec unicorn -D, without bothering about writing an after_fork and it works out of the box. The main process forks a worker process and that worker process hosts the scheduler thread.

I will write a piece of documentation to close this issue.