Awesome
heroku-alarm-clock
:clock9: cron node app to prevent heroku apps from sleeping.
How it works?
Simple: any X minutes a cron job will ping all the url's (heroku apps) you have configured. The job will also be schedule to be executed any hour/s you want. Notice that free heroku apps should be asleep at least 6 hours per day.
Pre Requisites
I am using the free online subscription of redislab
Install
- Clone or download the repo.
- Open a terminal and locate the repo directory.
- Run:
$ npm i
Set Up
You need to run the application with these environment variables:
PING_MINUTES
-> integer value from 1 to 59PING_HOURS
-> list of all hours separated with ','PING_URLS
-> list of all heroku apps url's separated with ','REDIS_URL
-> redis db connection string
```
PING_MINUTES=30
PING_HOURS=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
PING_URLS=http://my-domain.com,http://my-domain2.com
REDIS_URL=redis://redisHost.com:17411
```
The app is using dotenv nodejs module to emulate environment variables. You can create a .env
file at the root of the repo and put all the settings there (check the sample.env
demo file).
Runt It
- Open a terminal and locate the repo directory.
- Run:
$ PING_MINUTES='30' PING_HOURS='6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23' PING_URLS='http://my-domain.com;http://my-domain2.com' REDIS_URL='redis://redisHost.com:17411' node server
Run using .env
file
- Open a terminal and locate the repo directory.
- Run:
$ node server