Deploying

Hosting for Node Knockout in 2015 is provided by Modulus.io. This page aims to give you the essential stuff you need to to deploy your app. We’ll be available via email or IRC at anytime during the competition to try and solve any issues you might run into. We’ll keep this page up to date as questions come in.

Full documentation for the Modulus.io hosting platform is available here.

1) Verify you have access to your Github repo.

You should have received an invite from Github to join a new team within organization nko5. Please accept this invite in order to access your Git repository for the competition. If you didn’t receive it via email, go to http://github.com/nko5 to accept the invite to the repo.

The url for your NKO 2015 repository should look like: github.com/nko5/<your team>.

2) Set up your Modulus account.

A Modulus.io user account was created for each team participant, you should have received an email from Modulus with a link to “Reset Password”. It will ask you to set a password that can be used for subsequent steps.

If you didn’t receive this email, please let us know ASAP.

3) Install Modulus CLI

The cli commands are used to deploy your project to Modulus.io. Install the CLI via npm:

$ npm install -g modulus

4) Login to Modulus

$ modulus login

Welcome to Modulus

[?] Enter your email: pparker@gmail.com
[?] Enter your password:
[✓] Signed in as user spiderman

5) Deploy Your Project

$ cd path/to/repo
$ modulus deploy
[?] Are you sure you want to use project Lizard Locator? (yes)
Compressing project...
6.6 MB written
Uploading project...
Upload progress [===================] 100%
Deploying Project...
Deploying [       =            ]
[✓] Lizard Locator running at nko2015-lizard-locator-895.onmodulus.net

View project logs

Access the last 2000 lines of logs from your project.

$ modulus project logs

Start / Stop / Restart your project

$ modulus project restart

$ modulus project stop

$ modulus project start

Configure Environment variables

Create an Environment variable

$ modulus env set CUSTOM_VAR_C custom_value_3
Setting CUSTOM_VAR_C for project ExampleProject
[✓] Successfully set environment variable.

Your project environment variable will be accessible via process.env.CUSTOM_VAR_C.

List Current Variables

$ modulus env list
Project ExampleProject Environment Variables
NODE_ENV = production
CUSTOM_VAR_A = custom_value
CUSTOM_VAR_B = custom_value_2

Delete an Environment variable

modulus env delete CUSTOM_VAR_C            

Learn more about Environment variables.

Your MongoDB Database

You can add a MongoDB to your project with a simple command:

$ modulus addons add mongo:base

This will create an ENV variable called MONGO_URL. You can use this with any node.js MongoDB client.

var MongoClient = require('mongodb').MongoClient;

MongoClient.connect( process.env.MONGO_URL, function(err, db) {
  // Query the DB.
});          

The MongoDB that is created is 3.x. If your local mongodb client tools are v2, please upgrade.

If you would prefer to use PostgreSQLRethinkDBElasticSearchRabbitMQ, or etcdcontact us and we’ll set you up as soon as possible.

Redis Database

If you need a Redis DB for your project, you can register for a free DB from RedisGreen here.

Setting the Node.js version of your app

By default all projects use the latest stable version Node.js (4.x.x).

Specify a version for your project with your package.json.

{
  "engines": {
    "node": "0.10.38"
  }
}

Learn more about Setting the Node Version.