Using the Heroku scheduler

It is easy to set up a keep-alive dyno ping using the Heroku scheduler. If you are a Ruby developer, you can create a rake task as follows, for an automated ping to your web dyno:

  1. Write the following script:
    desc "Pings YOUR_HEROKU_APP_URL to keep a dyno alive"
        task :wakeup_dyno do
          require "net/http"
          if ENV['YOUR_HEROKU_APP_URL']
            uri = URI(ENV['YOUR_HEROKU_APP_URL'])
  2. Add YOUR_HEROKU_APP_URL to your Heroku environment:
    $ heroku config:add YOUR_HEROKU_APP_URL=
  3. Now, set up the Heroku scheduler:
    $ heroku addons:add scheduler:standard
    $ heroku addons:open scheduler

    That last command should open the scheduler interface in your browser.

  4. Set up your wakeup_dyno ...

Get Heroku Cloud Application Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.