Reputation: 79
I've small app(git) on node on Heroku that works with api for vk.com(social network), but Heroku kills it with SIGTERM after 30 min. I use setInterval which sends request to vk.com server and processes the response once every 20 min:
var timerID = setInterval( function reposting() {
vk.executes("wall.get", [
{owner_id: -97758272, count: 1, extended: true},
{owner_id: -109933725, offset: 1, count:1, extended: true}
])
.then((wall_list) => {
wall_list.forEach(function(wall, index) {
repost_and_join(wall, index);
});
})
.catch((error) => {
console.log("WALL_GET_ERROR: "+error);
});
}, 600000);
How to fix this problem, or maybe you know another free hosting where can deploy an app like this? ERRORLOG:
Upvotes: 1
Views: 8254
Reputation: 79
Just add something like this in your code:
var reqTimer = setTimeout(function wakeUp() {
request("https://nameless-gorge-19527.herokuapp.com", function() {
console.log("WAKE UP DYNO");
});
return reqTimer = setTimeout(wakeUp, 1200000);
}, 1200000);
Upvotes: 2
Reputation: 7267
Free dynos are unique because they go to sleep after 30 minutes of inactivity.
From Heroku devcenter
Are you using free dynos by any chance?
If you're looking for a free service, maybe give aws lambda a try? They give you 1M free call per month i think, IIRC
Upvotes: 3