Giter VIP home page Giter VIP logo

hubot-heroku-keepalive's Introduction

hubot-heroku-keepalive

A hubot script that keeps the hubot Heroko web dyno alive.

Installation

In hubot project repository, run:

npm install hubot-heroku-keepalive --save

Then add hubot-heroku-keepalive to your external-scripts.json:

[
  "hubot-heroku-keepalive"
]

Configuring

hubot-heroku-keepalive is configured by four environment variables:

  • HUBOT_HEROKU_KEEPALIVE_URL - the URL to keepalive
  • HUBOT_HEROKU_KEEPALIVE_INTERVAL - the interval in which to keepalive, in minutes
  • HUBOT_HEROKU_WAKEUP_TIME - optional, the time of day (HH:MM) when hubot should wake up. Default 6:00 (6 am)
  • HUBOT_HEROKU_SLEEP_TIME - optional, the time of day (HH:MM) when hubot should go to sleep. Default 22:00 (10 pm)

In May, 2015, Heroku introduced a new pricing tier doing away with a 24/7 free dyno. HUBOT_HEROKU_WAKEUP_TIME and HUBOT_HEROKU_SLEEP_TIME define the waking hours - between these times the keepalive will ping your Heroku app. Outside of those times, the ping will be surpressed allowing the dyno to shut down. Accessing your Hubot during a sleep period will wake it, but it will return to sleep after 30 minutes.

HUBOT_HEROKU_WAKEUP_TIME and HUBOT_HEROKU_SLEEP_TIME are times based on the timezone of your Heroku application which defaults to UTC. You can change this with heroku config:add TZ="America/New_York".

You must still implement a process to wake the heroku app up in the morning, such as a cron job or a custom command that posts to your heroku instance from your chat.

For hubot-heroku-keepalive to be useful, you must at least set HUBOT_HEROKU_KEEPALIVE_URL. You can find out the value for this by using the Heroku Toolbelt:

heroku apps:info

Copy the Web URL, and then config:set HUBOT_HEROKU_KEEPALIVE_URL:

heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=PASTE_WEB_URL_HERE

If you want to trust a shell snippet from the Internet, here's a one-liner:

heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web_url | cut -d= -f2)

Legacy Support

Hubot has for a long time had it's own builtin way to keep its web dyno alive, but this is an extraction of that behavior.

The legacy support uses the HEROKU_URL environment variable instead of HUBOT_HEROKU_KEEPALIVE_URL, so for forward compatability, hubot-heroku-keepalive will also use HEROKU_URL if it's present, and will also disable the legacy keepalive behavior if it's present.

Development

The best way is to use npm link and make sure to point HUBOT_HEROKU_KEEPALIVE_URL at the right place:

hubot-heroku-keepalive$ npm link
hubot-heroku-keepalive$ cd /path/to/your/hubot
hubot$ npm link hubot-heroku-keepalive
hubot$ export HUBOT_HEROKU_KEEPALIVE_URL=http://localhost:8080/
hubot$ bin/hubot

hubot-heroku-keepalive's People

Contributors

technicalpickles avatar johnnaegle avatar despairblue avatar parkr avatar

Watchers

Bradley Temple avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.