A script to ping the heroku app dyno and prevent it from sleeping, with the notification for Mac OS for success and failure. This is a forked version of sharadcodes/herokuapp_pinger that is Mac OS-specific.
- crontab
- curl
If you choose to download the files, be sure to rename herokuapp_pinger_master
to herokuapp_pinger
.
-
Move the repository folder inside the
/Users/${USER}/
directory. This should be your ROOT user directory.It will look like:
/Users/${USER}/herokuapp_pinger/
-
Navigate to the
/herokuapp_pinger
directory:cd /Users/${USER}/herokuapp_pinger/
Open the script
pinger.sh
:vim pinger.sh
Replace the DUMMY_USER_NAME on the line 30 with your user name like this: `export HOME=/Users/your_user_name'
-
Run the following command to give yourself access to execute
pinger.sh
and create folders to store logs.chmod +x pinger.sh && mkdir logs && mkdir csv_logs
These two folders will be used to store logs.
csv_logs
folder will store logs in the form of CSV files and thelogs
folder will store them with.log
extension -
Add the hosts to the
hosts_list.txt
file insideherokuapp_pinger/script_data
folder.Every host url should be on a new line
NOTE: There should be a new empty line after the last host otherwise last entry in the file will not be read
ALSO ANY NUMBER OF HOSTS CAN BE SPECIFIED IN THE
hosts_list.txt
file -
Setup crontab like this:
chrontab -e
And add the following line to your
chrontab
editor.* * * * * /home/your_user_name/herokuapp_pinger/pinger.sh
You should change the crontab schedule according to your needs as * * * * * will run the script every minute
I ping my Heroku website every 30 minutes.
-
Test the script by running
./pinger.sh
The script should: create two log files, run with no errors to the console, and display a notification with your hostname as the title and the status as the body.
To turn off notifications, simply remove the
display notifications
(line 47) from.pinger.sh
.
/home/${USER}/herokuapp_pinger/logs/
/home/${USER}/herokuapp_pinger/csv_logs/