问题
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