CharlieHess / slack-poker-bot

A bot that deals Texas Hold'em games in Slack
MIT License
1.66k stars 208 forks source link

Heroku app sleeping #26

Closed jiserra closed 8 years ago

jiserra commented 8 years ago

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!

stephenyeargin commented 8 years ago

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/

jiserra commented 8 years ago

That worked perfectly, thanks, great tip!

lukekarrys commented 8 years ago

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 :smile:

stephenyeargin commented 8 years ago

That doesn't seem right. Heroku shouldn't sleep if there is an active socket.

lukekarrys commented 8 years ago

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.