Thursday, October 30, 2014

Installing the NightScout CGM Remote Monitor on Heroku

It's again one of those nights... Max went to the movies and came back, you guessed it, a bit high. Since he is quite motivated to keep his blood sugars under control, he decided to inject a 1U correction and exercise a bit. So far so good. Bravo Max. Of course, he got a bit enthusiastic and overdid it. Since dad is condemned to a night watch, he might as well be productive.

Heroku? (

Heroku is a cloud application platform. Just like Azure, it can run Node.JS based applications (and many others). That means that it can also run the remote-monitor (web page) part of NightScout, the remotely accessible real-time interstitial glucose monitoring tool.

While I run my normal monitor on a local system and a private server, it never hurts to have a backup. Why Heroku instead of Azure? Here are my reasons.

  • the free Heroku plans don't seem to be as prone to failures, blue screens or other availability issues as Azure.
  • the free Heroku plan doesn't expire. No mandatory transition to paying plans (at least currently).
  • the free Heroku plan comes with SSL by default. (that doesn't add much confidentiality since the connection from the uploader to the database and from the portal to the database aren't encrypted).
  • Heroku salespeople don't bug you.
  • Access to the Heroku portal can be controlled after installing an add-on.
  • the portal can be installed through the command line (this last point may be a problem for a lot of users, but that is my preferred way of working)

Let's roll

This assume you have created a Github account and forked the cgm-remote-monitor project, as described in the NightScout setup guide.

1. Account creation

 Create a Heroku account on You'll need to enter an e-mail address, click on the confirmation e-mail you receive and choose a password.

2. Getting started

open your heroku account, locate the Node.JS icon in the "Get Started" section. Click on it.
3. Toolbelt

download and install the heroku toolbelt from the Set Up part of the tutorial.

The toolbelt contains the command line utilities and support tools required for interaction with Heroku.

4. Log in

when the install is complete, open a command window, move to the location of your choice on your computer and log into your heroku account by typing

heroku login

enter the e-mail address and password you entered to register with heroku. If you haven't used Heroku or other services using SSL based authentication, you will asked if you want to generate a key, answer "Y" for YES. You'll receive a mail notification that a key has been added to your account.

5. clone your github fork locally (replace xxxxxxx with your Github user name)

git clone
 that will create a local copy of the git repository (that you can eventually also use for experiments). Once the cloning is complete, change to that directory so the Heroku toolbelt knows which repository you are working with.

cd cgm-remote-monitor

6. create a heroku application 

heroku create --http-git
you will get a message and a name such as nameless-owl-3456.git. This will be your app identifier (you can change later) and a part of your connection url.

7. push the application on the server

git push heroku master
you'll see a lot of messages - they should succeed. Heroku has now linked the code of your portal to an application. The application should immediately be visible. Log into your heroku control panel to check.You'll see your application. Click on it and then go to its settings. This is now, before we start the application, that we add the config variables (or "strings") that you saved in your mongo database creation and entered in the uploader. They are the glue between the monitor and the database. Define your "mongo" string and your "mongo_collection" as shown below, with your information of course.

8. Starting the portal
When the strings have been entered and double checked, you can start the application by typing.

heroku ps:scale web=1
you'll get the message below. It means that your application started on one "dyno", a dyno is a kind of small virtual machine.
Scaling dynos... done, now running web at 1:1X.

9. Opening the portal
Open the portal by typing
heroku open

This should open the web site in your default browser.
Your NightScout portal is now running. Congratulations!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.