UNPKG

brobbot

Version:

A simple helpful robot for your Company

88 lines (68 loc) 3.17 kB
# Deploying Brobbot to Heroku If you've been following along with [Getting Started](../README.md), it's time to deploy so you can use it beyond just your local machine. [Heroku](http://www.heroku.com/) is an easy and supported way to deploy brobbot. Install the [Heroku Toolbelt](https://toolbelt.heroku.com/) to start, then follow their 'Getting Started' instructions, including logging in the first time: ```bash % heroku login Enter your Heroku credentials. Email: youremail@example.com Password: Could not find an existing public key. Would you like to generate one? [Yn] Generating new SSH public key. Uploading ssh public key /Users/you/.ssh/id_rsa.pub ``` Inside your new [brobbot-instance](https://github.com/b3nj4m/brobbot-instance) directory, make sure you've created a git repository, and that your work is committed: ```bash % git init % git add . % git commit -m "Initial commit" ``` Then create a Heroku application: ```bash % heroku create Creating rosemary-britches-123... done, stack is cedar http://rosemary-britches-123.herokuapp.com/ | git@heroku.com:rosemary-britches-123.git Git remote heroku added ``` Before you deploy the application, you'll need to configure some environment variables for brobbot to use. The specific variables you'll need depends on which [adapter](../adapters.md) and scripts you are using. For Slack, with no other scripts, you'd need to set the following environment variables: ```bash % heroku config:set BROBBOT_SLACK_TOKEN=your-slack-token ``` In addition, there is one special environment variable for Heroku. The default brobbot [Procfile](https://devcenter.heroku.com/articles/procfile) marks the process as a 'web' process type, in order to support serving http requests (more on that in the [scripting docs](../scripting.md)). The downside of this is that dynos will [idle after an hour of inactivity](https://devcenter.heroku.com/articles/dynos#dyno-idling). That means your brobbot would leave after an hour of idle web traffic, and only rejoin when it does get traffic. This is extremely inconvenient since most interaction is done through chat, and brobbot has to be online and in the room to respond to messages. To get around this, there's a special environment variable to make brobbot regularly ping itself over http. If the app is deployed to http://rosemary-britches-123.herokuapp.com/, you'd configure: ```bash % heroku config:set HEROKU_URL=http://rosemary-britches-123.herokuapp.com ``` At this point, you are ready to deploy and start chatting. With Heroku, that's a git push away: ```bash % git push heroku master ``` You'll see some text flying, and eventually some success. You should be able to see your bot in your configured chat rooms at this point. If not, you can peek at the logs to try to debug: ```bash % heroku logs ``` If you make any changes to your brobbot, just commit and push them as before: ```bash % git commit -am "Awesome scripts OMG" % git push heroku master ``` Some scripts needs Redis to work, Heroku offers an addon called [Redis To-Go](https://addons.heroku.com/redistogo), which has a free plan. To use it: ```bash % heroku addons:add redistogo:nano ```