-
Notifications
You must be signed in to change notification settings - Fork 703
Deploy to Heroku
The following documents how to setup and deploy uptime to Heroku. Some of these steps could be combined but are separated for clarity.
Create Heroku App
$ heroku apps:create heroku-uptime
Add MongoLab Add-on
$ heroku addons:add mongolab
Add WebSSocket Support
$ heroku labs:enable websockets
Add PaperTrail (Optional, but very handy for debugging)
$ heroku addons:add papertrail
Heroku creates the environment variable, MONGODB_URI but we are still forced to provide a username and password (see bootstrap.js). Set your config variables. Mileage seems to improve if the URI is fully deconstructed.
$ heroku config
=== heroku-uptime Config Vars
MONGOLAB_URI: mongodb://YourAwesomeUsername:YourAwesomePassword@<subdomain.mongolab.com>:<port>/YourAwesomeDatabaseName
$ heroku config:add MONGOLAB_USERNAME=YourAwesomeUsername MONGOLAB_PASSWORD=YourAwesomePassword
Setting config vars and restarting uptime-demo... done, v2
MONGOLAB_USERNAME: YourAwesomeUsername
MONGOLAB_PASSWORD: YourAwesomePassword
MONGOLAB_DATABASE: YourAwesomeDatabaseName
MONGOLAB_SERVER: <subdomain.mongolab.com>:<port>
Set the environment for node-config
$ heroku config:add NODE_ENV=demo
Create the config/demo.js file. A .js file is used instead of a .yaml file so environment variables can be used. Remember, the name of this file needs to correspond to the name of the environment set in the previous step!
// demo.js
module.exports = {
mongodb: {
user: process.env.MONGOLAB_USERNAME,
password: process.env.MONGOLAB_PASSWORD,
database: process.env.MONGOLAB_DATABASE,
server: process.env.MONGOLAB_SERVER
},
monitor: {
apiUrl: process.env.UPTIME_API_URL
},
verbose: false
}
Add the new config file to git
git add config/demo.js
And commit
git commit -m "Initial config"
Push your repo to Heroku
$ git push heroku master
Navigate to your app, https://heroku-uptime.herokuapp.com. Note the use of the HTTPS endpoint.
You're now monitoring uptime in the cloud!