Created
October 15, 2016 07:16
-
-
Save timkofu/b357dd96835461bb1b58c9b4267632ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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