”2016-09-30”

This commit is contained in:
Martin Donnelly 2016-09-30 16:45:02 +01:00
parent 5d7b75e9e9
commit f3dba8b6f0
4 changed files with 29 additions and 18 deletions

View File

@ -19,15 +19,26 @@ var localCN = {
// ElephantSql settings // ElephantSql settings
var remoteCN = { /*var remoteCN = {
host: 'jumbo.db.elephantsql.com', host: 'jumbo.db.elephantsql.com',
port: 5432, port: 5432,
database: 'amlrxqev', database: 'amlrxqev',
user: 'amlrxqev', user: 'amlrxqev',
password: 'K11cvCplk0--oNafsYj4ISN-rVQmVS3y' password: 'K11cvCplk0--oNafsYj4ISN-rVQmVS3y'
};*/
var amazonCN = {
dbinstance:'CensisMDot',
host: 'censis.cew5a5td5ukl.eu-west-1.rds.amazonaws.com',
port: 5432,
database: 'mdot',
user: 'censis_Lm5zt9BYD',
password: '1bR9nJoC5cFRcO84lu5mzmA7MeKyRW'
}; };
const cn = process.env.NODE_ENV === 'production' ? remoteCN : localCN; const cn = process.env.NODE_ENV === 'production' ? amazonCN : localCN;
exports.dbConnection = pgp(cn); exports.dbConnection = pgp(cn);

View File

@ -11,14 +11,6 @@ var requestify = require('requestify');
var db = require('../server/db-connector').dbConnection; var db = require('../server/db-connector').dbConnection;
var dbSave = require('../server/db-save')(db); var dbSave = require('../server/db-save')(db);
var pusher = require('../pusher');
//var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984');
/*
var nano = require('nano')('http://localhost:5984');
var db_name = 'mqttarchive';
var dbCouch = nano.use(db_name);
*/
//let remoteHost = process.env.NODE_ENV === 'production' ? 'http://mdotserver.mybluemix.net/apiv2/message' : 'http://localhost:3011/apiv2/message'; //let remoteHost = process.env.NODE_ENV === 'production' ? 'http://mdotserver.mybluemix.net/apiv2/message' : 'http://localhost:3011/apiv2/message';
const remoteHost = process.env.NODE_ENV === 'production' ? 'http://ec2-52-211-111-57.eu-west-1.compute.amazonaws.com/apiv2/message' : 'http://localhost:3011/apiv2/message'; const remoteHost = process.env.NODE_ENV === 'production' ? 'http://ec2-52-211-111-57.eu-west-1.compute.amazonaws.com/apiv2/message' : 'http://localhost:3011/apiv2/message';
@ -95,8 +87,7 @@ var watchDogTimeout = () => {
'Watchdog timeout. Message has not been received for over 20 minutes.'); 'Watchdog timeout. Message has not been received for over 20 minutes.');
logger.warn('Last received:' + lastReceived + 'Now:' + now); logger.warn('Last received:' + lastReceived + 'Now:' + now);
pusher.push(
'Watchdog timeout. Message has not been received for over 20 Minutes. \n\nLast received:' + lastReceived + 'Now:' + now);
wdTimedOut = true; wdTimedOut = true;
}; };
@ -131,7 +122,6 @@ var mqttClient = function() {
// connected = true; // connected = true;
logger.info('Connected to ', address); logger.info('Connected to ', address);
pusher.push('Connected to ' + address);
clearTimeout(watchDog); clearTimeout(watchDog);
watchDog = setTimeout(watchDogTimeout, 1200000); watchDog = setTimeout(watchDogTimeout, 1200000);
lastReceived = new Date(); lastReceived = new Date();
@ -188,7 +178,7 @@ var mqttClient = function() {
var now = new Date(); var now = new Date();
var s = 'Receiving again :::\n\nLast received: ' + lastReceived + 'Now: ' + now + "\n\n" + message.toString(); var s = 'Receiving again :::\n\nLast received: ' + lastReceived + 'Now: ' + now + "\n\n" + message.toString();
logger.warn(s); logger.warn(s);
pusher.push(s);
wdTimedOut = false; wdTimedOut = false;
} }
lastReceived = new Date(); lastReceived = new Date();
@ -205,7 +195,7 @@ var mqttClient = function() {
this.getCount = function() { this.getCount = function() {
'use strict'; 'use strict';
return count; return count;
} };
}; };

View File

@ -19,15 +19,24 @@ var localCN = {
// ElephantSql settings // ElephantSql settings
var remoteCN = { /*var remoteCN = {
host: 'jumbo.db.elephantsql.com', host: 'jumbo.db.elephantsql.com',
port: 5432, port: 5432,
database: 'vmlcokon', database: 'vmlcokon',
user: 'vmlcokon', user: 'vmlcokon',
password: 'PQUYLiIW4M6r7SWyZevrES_rRAULYFkp' password: 'PQUYLiIW4M6r7SWyZevrES_rRAULYFkp'
};*/
var amazonCN = {
dbinstance:'CensisMDot',
host: 'censis.cew5a5td5ukl.eu-west-1.rds.amazonaws.com',
port: 5432,
database: 'mdot',
user: 'censis_Lm5zt9BYD',
password: '1bR9nJoC5cFRcO84lu5mzmA7MeKyRW'
}; };
const cn = process.env.NODE_ENV === 'production' ? remoteCN : localCN; const cn = process.env.NODE_ENV === 'production' ? amazonCN : localCN;
exports.dbConnection = pgp(cn); exports.dbConnection = pgp(cn);

View File

@ -6,7 +6,8 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node app.js", "start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1",
"production": "NODE_ENV=production node app.js"
}, },
"dependencies": { "dependencies": {
"atob": "^2.0.3", "atob": "^2.0.3",