From a22ec4c5349aeba9299bf876bcf69cb29aeb2392 Mon Sep 17 00:00:00 2001 From: Ben West Date: Wed, 19 Nov 2014 13:46:33 -0800 Subject: [PATCH 1/6] add forever.js: make server run forever This helps with heroku and other non-azure hosts. --- Procfile | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index 489b2700aca..b62d80ef5af 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: node server.js +web: ./node_modules/.bin/forever server.js diff --git a/package.json b/package.json index 9fa88c37110..1b2f4675ab8 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "pushover-notifications": "0.2.0", "sgvdata": "0.0.2", "socket.io": "^0.9.17", - "git-rev": "git://github.com/bewest/git-rev.git" + "git-rev": "git://github.com/bewest/git-rev.git", + "forever": "~0.13.0" }, "devDependencies": { "supertest": "~0.13.0", From 079fe495db93a6f4dc1b436ff63ca623366d01f7 Mon Sep 17 00:00:00 2001 From: Ben West Date: Fri, 21 Nov 2014 12:06:29 -0800 Subject: [PATCH 2/6] tweak how forever runs --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index b62d80ef5af..f5d45241167 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: ./node_modules/.bin/forever server.js +web: ./node_modules/.bin/forever start -c server.js From 812d028008912f361b8df80b02832d754833f05a Mon Sep 17 00:00:00 2001 From: Ben West Date: Fri, 21 Nov 2014 15:24:59 -0800 Subject: [PATCH 3/6] tweak forever to restart things Found that the parameters didn't work as advertised unless done like this. --- Procfile | 2 +- lib/storage.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Procfile b/Procfile index f5d45241167..32dd1c83adc 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: ./node_modules/.bin/forever start -c server.js +web: ./node_modules/.bin/forever --minUptime 100 -c node server.js diff --git a/lib/storage.js b/lib/storage.js index 58a965a7d87..6a02a83f25a 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -1,5 +1,7 @@ 'use strict'; var mongodb = require('mongodb'); +var levelup = require('levelup'); +var mongodown = require('mongo-down'); function init (env, cb) { var MongoClient = mongodb.MongoClient; @@ -11,6 +13,9 @@ function init (env, cb) { if (cb && cb.call) { cb(null, mongo); } return; } + if (!env.mongo) { + throw new Error("Mongo string is missing"); + } console.log("Connecting to mongo"); MongoClient.connect(env.mongo, function connected (err, db) { if (err) { From 4f0758a8a83c2f0ec4d2448bad5c048daaba1c0a Mon Sep 17 00:00:00 2001 From: Ben West Date: Fri, 21 Nov 2014 15:34:07 -0800 Subject: [PATCH 4/6] oops, remove spurious modules --- lib/storage.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/storage.js b/lib/storage.js index 6a02a83f25a..d5b128a0592 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -1,7 +1,5 @@ 'use strict'; var mongodb = require('mongodb'); -var levelup = require('levelup'); -var mongodown = require('mongo-down'); function init (env, cb) { var MongoClient = mongodb.MongoClient; From 88a09eec26562bcbb878dc8e19e3e8d72c76d967 Mon Sep 17 00:00:00 2001 From: Ben West Date: Sat, 21 Mar 2015 14:46:07 -0700 Subject: [PATCH 5/6] make ENABLE optional --- env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env.js b/env.js index 38f4822df75..528c1d16c7d 100644 --- a/env.js +++ b/env.js @@ -45,7 +45,7 @@ function config ( ) { env.profile_collection = readENV('MONGO_PROFILE_COLLECTION', 'profile'); env.devicestatus_collection = readENV('MONGO_DEVICESTATUS_COLLECTION', 'devicestatus'); - env.enable = readENV('ENABLE'); + env.enable = readENV('ENABLE', ""); env.SSL_KEY = readENV('SSL_KEY'); env.SSL_CERT = readENV('SSL_CERT'); env.SSL_CA = readENV('SSL_CA'); From 4cfcb307de73d1c0b841622e3b59d3982a7a681c Mon Sep 17 00:00:00 2001 From: Ben West Date: Sat, 21 Mar 2015 14:50:52 -0700 Subject: [PATCH 6/6] fix mqtt client id for digitalocean/dokku Dokku doesn't have git repo as root. --- env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env.js b/env.js index 528c1d16c7d..156ed90052f 100644 --- a/env.js +++ b/env.js @@ -27,7 +27,7 @@ function config ( ) { } else { git.short(function record_git_head (head) { console.log("GIT HEAD", head); - env.head = head; + env.head = head || readENV("SCM_COMMIT_ID", ""); }); } env.version = software.version;