Skip to content

Instantly share code, notes, and snippets.

benstuijts /
Created May 6, 2016 — forked from learncodeacademy/
Deploy Node.js app on Ubuntu as Upstart Service - instead of using Forever

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start
benstuijts /
Created May 7, 2016 — forked from learncodeacademy/
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
benstuijts / gist:8e4d7c4430423811ae398c5fb53a8827
Created May 9, 2016 — forked from learncodeacademy/gist:ebba574fc3f438c851ae
Nginx Node Frontend / Load Balancer / Static Assets Caching
View gist:8e4d7c4430423811ae398c5fb53a8827
upstream project {
server {
listen 80;
location / {
benstuijts / pubsub.js
Created May 15, 2016 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
View pubsub.js
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {[eventName] =[eventName] || [];[eventName].push(fn);
off: function(eventName, fn) {
if ([eventName]) {