I'm running a Node.js app on Heroku for free. People use New Relic for pinging their app constantly, preventing the dyno from idling, but New Relic does not support Node. Does anyone know of an alternative add-on that supports Node? I don't care about features, I just need it to ping once every <1 hr.
Tested and working on my own Heroku app using Node.js 0.10.x on 6/28/2013
var http = require('http'); //importing http
function startKeepAlive() {
setInterval(function() {
var options = {
host: 'your_app_name.herokuapp.com',
port: 80,
path: '/'
};
http.get(options, function(res) {
res.on('data', function(chunk) {
try {
// optional logging... disable after it's working
console.log("HEROKU RESPONSE: " + chunk);
} catch (err) {
console.log(err.message);
}
});
}).on('error', function(err) {
console.log("Error: " + err.message);
});
}, 20 * 60 * 1000); // load every 20 minutes
}
startKeepAlive();
Pingdom should work for that. The Heroku add-on catalog has lots of other monitoring add-ons that should also work great.
There's also uptime : a nice Node.js monitoring tool. Free, open source, extensible through plugins, must be installed manually. One can defines the "ping" frequency down to the second.