Skip to content

Commit

Permalink
npm update / mongo fix / small fixes (#3413)
Browse files Browse the repository at this point in the history
* npm update and test if nodejs 9.x (currently 9.7.1) also works

* explicit node version in .travis.yml

* add webpack-cli

* UglifyJsPlugin is deprecated in webpack 4. It's used as --optimize-minimize as default

* improve Readme

* update some more

* fix typo in .travis.yml and remove node 9.7.1 because Travis does not seem to support it

* upgrade simple-statistics.

Use standardDeviation instead of standard_deviation. Other functions are not changed.
try node 9 on travis

* downgrade async to 1.5.2 to see if that makes the test work again

* downgrade async module and fix tests

* npm update

* update npm in package.json

* restore RMS in glucosedistribution

* remove unused total
use SI units (L instead of l, min instead of m)

* improve mongo

* apply fix suggested by Paul Andrel @stavlor, see https://gitter.im/nightscout/public?at=5ab542f135dd17022e92891a

* npm update

* fix mongodb, remove ancient npm versions. azure has 5.7
j

* revert to simple-stats 0.7.0

* add bundle-dev option to package.json

* fix distribution test

* upgrade nvm version for travis to latest nvm.

once node 8 and node 9 ship with npm > 5.6.0 we should remove this. see npm/npm#17858 for details
  • Loading branch information
PieterGit authored and scottleibrand committed Apr 24, 2018
1 parent 71e8f3a commit 92874d7
Show file tree
Hide file tree
Showing 6 changed files with 10,318 additions and 5,396 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ language: node_js
sudo: required
dist: trusty
node_js:
- "8.9.3"
before_install: if [[ `npm --version` != "5.6" ]]; then npm install -g npm@latest; npm --version; fi
- "8"
- "9"
before_install: if [[ `npm --version` != "5.8.0" ]]; then npm install -g npm@latest; npm --version; fi
matrix:
fast_finish: true
services:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ Community maintained fork of the

Requirements:

- [Node.js](http://nodejs.org/) 8.9.0 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
- [Node.js](http://nodejs.org/) 8.11.0 LTS or later or [Node.js](http://nodejs.org/) 9.10.0 or later. Use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
- [MongoDB](https://www.mongodb.com/download-center?jmp=nav#community) 3.x. MongoDB 2.4 is only supported for Raspberry Pi.

Clone this repo then install dependencies into the root of the project:

Expand Down
20 changes: 12 additions & 8 deletions lib/storage/mongo-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ function init (env, cb, forceNewConnection) {
var connect_with_retry = function(i) {
return MongoClient.connect(env.storageURI, options, function connected(err, client) {
if (err) {
if (err.includes('Invalid schema')) { throw new Error('MongoDB connection string seems invalid'); }
if (i>20) {
// Abort after retrying for more than 10 minutes
throw 'Error connecting to MongoDB, stopping the retry loop and aborting...';
//console.log('err=', err)
if (err.name && err.name === "MongoNetworkError") {
if (i>20) {
// Abort after retrying for more than 10 minutes
throw 'Error connecting to MongoDB, stopping the retry loop and aborting...';
}
console.log('Error connecting to MongoDB: %j - retrying in ' + i*3 + ' sec', err);
setTimeout(connect_with_retry, i*3000, i+1);
} else if (err.message) {
throw new Error('MongoDB connection string '+env.storageURI+' seems invalid: '+err.message) ;
}
console.log('Error connecting to MongoDB: %j - retrying in ' + i*3 + ' sec', err);
setTimeout(connect_with_retry, i*3000, i+1);
} else {
console.log('Successfully established a connected to MongoDB');

var dbName = env.storageURI.split('?').pop().split('/');
dbName = dbName[dbName.length -1];
var dbName = env.storageURI.split('/').pop().split('?');
dbName=dbName[0]; // drop Connection Options
mongo.db = client.db(dbName);
connection = mongo.db;
mongo.client = client;
Expand Down
Loading

0 comments on commit 92874d7

Please sign in to comment.