Skip to content

Instantly share code, notes, and snippets.

@timkofu
Created October 15, 2016 07:16
Show Gist options
  • Save timkofu/b357dd96835461bb1b58c9b4267632ad to your computer and use it in GitHub Desktop.
Save timkofu/b357dd96835461bb1b58c9b4267632ad to your computer and use it in GitHub Desktop.
# Keeps heroku free dyno from sleeping
# Runs from cron every 29 minutes
import requests
import gevent
from gevent import monkey
monkey.patch_all()
def keep_em_up(site):
requests.head(site, headers={
'User-Agent': "timkofu's dyno caffeine 0.1"
})
if __name__ == '__main__':
sites = [
'http://www.whatever.co.ke',
'http://www.whatever.com'
]
gevent.joinall(
[gevent.spawn(keep_em_up, s) for s in sites]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment