Heroku app sleeping
Closed this issue · 5 comments
Hi,
I used the "lazy" method of deploying to Heroku and the app appears as "sleeping" on my Personal Heroku app list. I've put the token and I configured a BOT on Slack but the bot appears to be offline and I don't really know how to start it. Any tips?
Thanks!
You should be able to hit the endpoint, e.g. http://calm-monkey-255.herokuapp.com
to wake it back up after about 20 seconds. That's our approach, as they eliminated the tier where you could leave a single dyno running in perpetuity. If you attempt one the approaches below, you'll get a daily email letting you know that the app is forced "sleeping" unless you're up for the $7 or so a month charge.
Related: https://quickleft.com/blog/6-easy-ways-to-prevent-your-heroku-node-app-from-sleeping/
That worked perfectly, thanks, great tip!
The one downside I've seen is that if you play for over an hour, the app can go to sleep in the middle of a game and the bot will disconnect.
I'm currently testing a fork where I'm doing an http.get
for the heroku app every 10 minutes inside main.js
(from the first method listed in the article linked by @stephenyeargin), but it only starts the interval when a game starts and clears the interval when the game ends.
I think this should work nicely since free heroku apps are allowed to be awake for 18 hours in any 24 hour rolling window which shouldn't be an issue unless you are playing a lot of Slack poker 😄
That doesn't seem right. Heroku shouldn't sleep if there is an active socket.
I'm probably wrong. I only remember the bot disconnecting during a game, so it could've been for other reasons. That was my first guess, but I never investigated further to confirm.