How To Heroku – An Alternative Hosting Solution (16-Jan-2015)

22 Nov
Guides > Labs > How To Heroku - An Alternative Hosting Solution (16-Jan-2015)

Note: Updated directions are available for setting up a Heroku site.

Drafted By:                            Greg Waehner and Jim Sifferle
Edited By:                              #WeAreNotWaiting
Last Updated:                      20-Feb-2015
Version:                                   0.5

Purpose:

This Nightscout Labs is intended to provide “do-it-yourself” (DIY) guidance on how to begin using Heroku as a complementary Nightscout Cloud Provider.

Disclaimer:

While Heroku is not “the Community standard” and the official documentation is not written using Heroku interfaces, this Lab demonstrates how just how simple Heroku is now. It is quicker to setup than Azure, does not have the “Mongo” outages that Azure has… so what’s the disclaimer… it may drive you to abandon Azure and adopt Heroku as your hosting solution before the rest of the Nightscout Support Team can update all the documentation and even train all our own personnel!!

Feedback:

This Lab is an evolving document. Please provide feedback, additional information, and recommendations for enhancements.

Preparation:

First, put your left foot in, take your left foot out… oh wait… this isn’t the Hokie Pokie… just checking to ensure you’re actually reading the Lab.

Comparison to Azure:

The benefits of using Heroku as a complement to, or replacement of your existing Azure hosting include:

  • Website site hosting that is separate from Azure in support of redundancy;
  • Supports WebSockets by default (a more efficient protocol for Nightscout website)
  • Data transfer does not appear to be limited;
  • Can set up 5 – 100 sites on one account (must be verified with credit card for 100);
  • Automated site creation capability;
  • Ability to have more technical capabilities such as command-line capabilities

Like Azure, Heroku…

  • Is free as long as you stay within its constraints (Note: the Heroku pricing model changed in 2015; sites are free if they sleep 6 hours a day. There is a fee for 24/7 sites.);
  • Provides SSL for data encryption;
  • Supports the REST API;
  • Integrates with GitHub; and
  • Has an “update your website” integration with GitHub (which was missing when this Lab was originally written in Nov. 2013).

However, Heroku has different terminology and interfaces – though that’s easy to overcome.

The following is written for the very initial setup – the first time user who has never setup anything before using Dreamsicle (cgm-remote-monitor Release/0.6.0)

Step 1: Create your Heroku Account

  1. Visit www.heroku.com and click the [Sign Up For Free] button.
  2. Submit your Email address and click the confirmation link in your Inbox.
  3. Choose a password.
  4. Do the credit card verification

Step 2: Create your Nightscout website for “cgm-remote-monitor”

From your GitHub repository for “cgm-remote-monitor,” scroll down to the README.md and click the “Deploy to Heroku” button

heroku 2

 

Step 3: Populate the data form

  • Name: Enter the name for your app – your website (e.g., NAME.herokuapp.com)
  • Region: Choose the region for your website
  • Env
    • Ensure “entries” is the collection name
    • Enter your “API_SECRET” value. This is the passcode for the REST API upload.
    • Set the ENABLE variable.  Include “careportal”, “rawbg” or both (e.g. careportal rawbg) to enable Care Portal and/or raw BG.
    • If you are going to enable custom alarm settings, enter your preferred values for ALARM_TYPES, BG_HIGH, BG_TARGET_TOP, BG_TARGET_BOTTOM, and BG_LOW
    • If you are going to use Pushover, then enter the PUSHOVER_API_TOKEN and PUSHOVER_USER_KEY.
  • Click “Deploy For Free”

 

heroku 2-1

 

Screen Shot 2015-01-29 at 8.35.30 PM

Screen Shot of Environment Variables

 

Congratulations! Your first Heroku-hosted Nightscout app has been created and/or configured.

 heroku 2-3

 

 Step 4: Configure Your Phone Uploader

  • Configure your phone uploader for REST API upload.
    • If your uploader is running 0.1.10 (Cookie Monster) or the original version of xDrip, set the REST API URL using the following format:

      API_SECRET@https://<sitename>.herokuapp.com/api/v1

    • If your uploader is running 0.1.12 (Dreamsicle) or a beta version of xDrip, set the REST API URL using the following format:

      https://API_SECRET@<sitename>.herokuapp.com/api/v1

 

Step 5: Verify It’s Working

To verify it’s working, you will used the “follow the data” methodology. The phone uploader using the REST API will send the SGV information to the Heroku app, which then stores it in the MongoLab database.

So within your Heroku App, click Resources, and then MongoLab.

heroku 5-1

 

This will bring up your MongoLab database where you can see the collections – and you entered “entries” as the collection name to store the SGV information.

 

Note: If you are asking yourself where the MongoLab database came from, then the quick answer is that the automated deployment process uses the free integrated “add-on” MongoLab capability and creates a MongoLab Account and database for the Heroku App. While you can discover most information about the database by looking, you can NOT discover the database user password. But you can see all the information, including the password, within the “Environment Variables.” However, the point of this automated deployment is that it abstracts away the persistence layer (the database) so you no longer need to be concerned about it. 

Now that you have gotten beyond “where the database came from,” you can return to verifying whether or not the uploader is successfully sending the SGV using the REST API to the Heroku app and getting stored in the MongoLab database collection – in short… is it working?

Once you see your “SGV collection” (entries) documents increasing, you know it is working. If that’s not sufficient because the website won’t render data until approximately 5 SGVs, then you can immediately verify using the pebble data endpoint URL.

heroku 5-2

 

Congratulations! You have successfully deployed ‘Nightscout’ (a.k.a. cgm-remote-monitor) to your first Heroku site, configured your uploader to utilize it with the REST API, and verified that it’s working end-to-end.

 

Step 6: Update Processes

In this updated (version 0.3) Labs version, Heroku has released native GitHub integration similar to and even better than Azure. As such, the recommendation is to use the GitHub integration — instead of other possible solutions available within Heroku — to have consistent processes and support whether you use Azure or Heroku.

To integrate GitHub with your Heroku App / Site, it could be the first site that you just created 5 seconds ago, or it could be a site you created 3 months ago. The following steps to add integration can be done with any existing app / site – the instructions are included in this Lab simply as an “end to end” how to get up and running on Heroku as a first time user.

    1. Find the site / app you just created by selecting “Personal Apps” on the left column.

UpdateProcesses_step1_personalapp

    1. Choose Deploy from the app toolbar.

Screen Shot 2015-01-29 at 8.46.27 PM

    1. Choose “Connect to GitHub.”

UpdateProcesses_step3_connectToGithub

    1. Choose “Connect to GitHub.”

UpdateProcesses_step4_connectToGithub

    1. By granting authorization, you are giving your Heroku app access to your GitHub (which you started from and used to create the site).

UpdateProcesses_step5_AuthApp

    1. If prompted, enter your GitHub password…

UpdateProcesses_step6_Password

    1. Once Heroku connects to Github, you will see something like this… your GitHub account and a “search box” for a repo-name (a.k.a. repository)

UpdateProcesses_step7_GitHubSearchRepo

    1. In the blank “repo-name” box, enter “cgm-remote“ and click the Search button. It should find one result, like below. Click the “Connect” button associated with your “[GitHub username]/cgm-remote-monitor”

UpdateProcesses_step8_GitHib_RepoConnect

    1. This will “link” the Heroku app to the repository…. You will get a screen like the following — and now the cool stuff begins….

UpdateProcesses_step9_Github_ConfigScreen

  1. Choose what type of code update methodology you want. On this screen, you can choose whether you want a manual update or an automatic update.
      • For the manual deployment, you can select a branch, and click Deploy Branch. The current state of that branch will be deployed.

    UpdateProcesses_step10_AutoDeployment

      • For the automated deployment, every update you make to the branch (generally, every update you make to your Master branch), will automatically be deployed. This is how GitHub integrates with Azure. However, with Heroku, you also have a choice of checking “Wait for CI to pass before deploy” which means that Continuous Integration tests must pass before the automated deployment will proceed. Make your choices, and then click “Enable Automatic Deploys”

    UpdateProcesses_step10_ManualDeployment

You are done!

One thought on “How To Heroku – An Alternative Hosting Solution (16-Jan-2015)

  1. Found the first mistake… For the Heroku site automated deploy, this was written based upon “development” branch. Right now, the MASTER branch only provides the collection, which you will need to rename to “entries.” The other variables can be added in from the App Dashboard, Config Vars. The instructions as written will be correct for the MASTER branch once the next set of patches are released.

Comments are closed.