How to get rufus-scheduler working with a Rails app deployed to Heroku?

白昼怎懂夜的黑 提交于 2019-12-03 08:39:28

Here's an example of how to get it to work on Rails:

#
# config/initializers/scheduler.rb
require 'rufus-scheduler'

# Let's use the rufus-scheduler singleton
#
s = Rufus::Scheduler.singleton

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

Take a look at the documentation.

You could instead use Heroku's Scheduler and move this task to work with Heroku's native tools : https://devcenter.heroku.com/articles/scheduler

I solved this problem just adding to my Procfile:

web: bundle exec passenger start -p $PORT --max-pool-size 3 --min-instances 2

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