Heroku - keeping a dyno alive (May 2013)

最后都变了- 提交于 2020-01-02 23:03:11

问题


Until now I used for this task the service called Pingdom, but yesterday I tried to sign up for a new application, but there is not the free plan anymore?

Anyway, I took a look for an alternative and I found New Relic could do this as well, but there is (in my eyes) one issue - we can set up an URL which we would like to ping, but this URL is pinged periodically each 30 seconds (and each 15 seconds if was detected an error).

Cannot this approach "overload" my app? There is also a way to set up the URL for pinging on an another page, for example not for index, but for

app.com/ping_url.html

But this doesn't solve this issue, or does? (becuase app is running on 1 Heroku instance)


回答1:


i used in a previous project the rufus sheduler.

install the rufus scheduler:

gem 'rufus-scheduler', :group => :production      

And set up an initializer: config/initializer/task_scheduler.rb

require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new

scheduler.every '4m' do
  require "net/http"
  require "uri"
  url = 'http://www.yourwebsite.de'
  Net::HTTP.get_response(URI.parse(url))
end


来源:https://stackoverflow.com/questions/16582011/heroku-keeping-a-dyno-alive-may-2013

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