DEV Community

loading...

A script to ping the heroku app dyno and prevent it from sleeping

Sharad Raj (He/Him)
Full Stack Developer | Intel AI Edge Scholar 2019 | Google India Scholar 2018 | Open for full time opportunities
・1 min read

herokuapp_pinger

A script to ping the heroku app dyno and prevent it from sleeping, with the notification for linux distros for success and failure

Repo

https://github.com/sharadcodes/herokuapp_pinger

SETUP

Requirements

  • crontab
  • notify-send
  • curl

STEPS

First of all clone the repository or download it

Extract the archive file and rename the folder from

herokuapp_pinger-master
Enter fullscreen mode Exit fullscreen mode

to

herokuapp_pinger
Enter fullscreen mode Exit fullscreen mode

Now follow the steps

  1. Place the repository folder inside the home/${USER}/ directory.

    It will look like:

    /home/${USER}/herokuapp_pinger/
    
  2. Open the script pinger.sh inside herokuapp_pinger folder with any text editor and replace the DUMMY_USER_NAME on the line 46 with your account name.

  3. Go inside the herokuapp_pinger folder and run

    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 the logs folder will store them with .log extension

  4. Add the hosts to the hosts_list.txt file inside herokuapp_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

  5. Setup crontab like this:

   * * * * * /home/your_user_name/herokuapp_pinger/pinger.sh
Enter fullscreen mode Exit fullscreen mode

You should change the crontab schedule according to your needs as

* * * * *
Enter fullscreen mode Exit fullscreen mode

will run the script every minute


Your logs will be inside

/home/${USER}/herokuapp_pinger/logs/
Enter fullscreen mode Exit fullscreen mode

and

/home/${USER}/herokuapp_pinger/csv_logs/
Enter fullscreen mode Exit fullscreen mode

SETUP FINISHED, ENJOY !

Discussion (0)