Heroku-使一个测力计活着(2013年5月) [英] Heroku - keeping a dyno alive (May 2013)

查看:75
本文介绍了Heroku-使一个测力计活着(2013年5月)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到现在,我将名为Pingdom的服务用于此任务,但是昨天我尝试注册一个新的应用程序,但是现在没有免费计划了吗?

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?

无论如何,我寻找了一个替代方法,我发现New Relic也可以做到这一点,但是(在我看来)有一个问题-我们可以设置一个我们想要ping的URL,但是这个URL每30秒(如果检测到错误,则每15秒)定期ping一次.

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).

这种方法无法超载"我的应用程序吗?还有一种方法可以设置URL以在另一个页面上执行ping操作,例如,不是为索引而是为

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

但这不能解决这个问题,或者可以吗? (因为应用程序在1个Heroku实例上运行)

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

推荐答案

我在先前的项目中使用了rufus sheduler.

i used in a previous project the rufus sheduler.

安装rufus调度程序:

install the rufus scheduler:

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

并设置一个初始化程序:config/initializer/task_scheduler.rb

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

这篇关于Heroku-使一个测力计活着(2013年5月)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆