Skip to content

Instantly share code, notes, and snippets.

@arifsetiawan
Last active August 29, 2015 14:06
Show Gist options
  • Save arifsetiawan/5f7e2d0a69306fbbd28f to your computer and use it in GitHub Desktop.
Save arifsetiawan/5f7e2d0a69306fbbd28f to your computer and use it in GitHub Desktop.
Deploy Node.js App

Deploy Node.js app

SSH to VM

$ ssh [email protected] -i MyAzure.key

Create setup script

$ nano init.sh

Copy these lines

# !/bin/sh
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential

# nodejs
sudo add-apt-repository -y ppa:chris-lea/node.js

# git
sudo add-apt-repository -y ppa:git-core/ppa

# update apt
sudo apt-get update

# install
sudo apt-get -y install nodejs git

Execute

$ chmod +x init.sh

$ ./init.sh

Run Node.js app

// install forever (https://github.com/nodejitsu/forever)
$ sudo npm install -g forever

// clone the app
$ git clone https://github.com/arifsetiawan/tasklist.git

$ cd tasklist

// install modules
$ sudo npm install

// edit start script. replace storage name and key with the one you have
$ nano runlinux_prod.sh

// run the app
$ ./runlinux_prod.sh

// check if the app is running
$ forever list

Test

$ curl http://azurecamp.cloudapp.net:3000/api/hello

Read the docs

http://azurecamp.cloudapp.net:3000/api

For development on your machine

Install nodemon (https://github.com/remy/nodemon)

$ npm install -g nodemon

edit start script. replace storage name and key with the one you have

$ nano runlinux_dev.sh

On windows, edit runwin_dev.cmd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment