Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Node 10. Upgrade to node 8.15.0 . Don't start on older Node versions #4155

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.12.x
8.x
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ If you plan to use Nightscout, we recommend using [Heroku](http://openaps.readth

Minimum browser requirements for viewing the site:

- iOS 9
- Android 4
- Chrome 42
- Safari 9 (El Capitan)
- Firefox 34
- Chrome 68
- Edge 15
- Firefox 61
- Internet Explorer: not supported
- Opera: not supported
- iOS 9
- Safari 11
- Opera: 54

Windows installation software requirements:

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

As a non-root user clone this repo then install dependencies into the root of the project:
Expand All @@ -140,16 +140,15 @@ As a non-root user clone this repo then install dependencies into the root of th
$ npm install
```

Installation notes for Microsoft Azure, Windows and Node 10:
Installation notes for Microsoft Azure, Windows:

- If deploying the software to Microsoft Azure, you must set ** in the app settings for *WEBSITE_NODE_DEFAULT_VERSION* and *SCM_COMMAND_IDLE_TIMEOUT* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting. Please use:
```
WEBSITE_NODE_DEFAULT_VERSION=8.11.1
WEBSITE_NODE_DEFAULT_VERSION=10.14.1
SCM_COMMAND_IDLE_TIMEOUT=300
```
- See [install MongoDB, Node.js, and Nightscouton a single Windows system](https://github.com/jaylagorio/Nightscout-on-Windows-Server). if you want to host your Nightscout outside of the cloud. Although the instructions are intended for Windows Server the procedure is compatible with client versions of Windows such as Windows 7 and Windows 10.
- If you deploy to Windows and want to develop or test you need to install [Cygwin](https://www.cygwin.com/) (use [setup-x86_64.exe](https://www.cygwin.com/setup-x86_64.exe) and make sure to install `build-essential` package. Test your configuration by executing `make` and check if all tests are ok.
- There may be some issues with Node 10.6.0 or later with Nightscout. Node 10 support will be in the 0.11 release. Please don't use Nightscout with (Node 9 or) Node 10 at this moment.

# Usage

Expand Down
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ function create(env, ctx) {
// serve the static content
app.use(staticFiles);

var swaggerFiles = express.static(env.swagger_files, {
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath();
var swaggerFiles = express.static(swaggerUiAssetPath, {
maxAge: maxAge
});

Expand Down
17 changes: 0 additions & 17 deletions bundle/index.js

This file was deleted.

1 change: 0 additions & 1 deletion env.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function config ( ) {
env.HOSTNAME = readENV('HOSTNAME', null);
env.IMPORT_CONFIG = readENV('IMPORT_CONFIG', null);
env.static_files = readENV('NIGHTSCOUT_STATIC_FILES', __dirname + '/static/');
env.swagger_files = readENV('NIGHTSCOUT_SWAGGER_FILES', __dirname + '/node_modules/swagger-ui-dist/');
env.debug = {
minify: readENVTruthy('DEBUG_MINIFY', true)
};
Expand Down
32 changes: 31 additions & 1 deletion lib/server/bootevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ var UPDATE_THROTTLE = 1000;

function boot (env, language) {

//////////////////////////////////////////////////
// Check Node version. Latest Node 8 LTS and Latest Node 10 LTS are recommended and supported.
// < 8 does not work, not supported
// >= 8.14.0 works, supported and recommended
PieterGit marked this conversation as resolved.
Show resolved Hide resolved
// == 8.11.1 works, not fully supported (this is the latest Node version on Azure; INSECURE)
// == 9.x does not work, not supported
// >= 10.14.2 works, supported and recommended
// >= 11.4.0 does not work, not recommended, will not be supported. We only support Node LTS releases
///////////////////////////////////////////////////
function checkNode (ctx, next) {
var semver = require('semver');
var nodeVersion = process.version;
if ( semver.satisfies(nodeVersion, '^8.15.0') || semver.satisfies(nodeVersion, '^10.15.0')) {
console.debug('Node version ' + nodeVersion + ' is supported');
next();
}
else if ( semver.eq(nodeVersion, '10.14.1')) {
console.log('WARNING: Node version v10.14.1 and Microsoft Azure are not recommended.');
console.log('WARNING: Please migrate to another hosting provider. Your Node version is outdated');
next();
} else {
// in all other cases don't start Node
console.log( 'ERROR: Node version ' + nodeVersion + ' is not supported. Please upgrade your Node');
process.exit(1);
}
}


function checkEnv (ctx, next) {
ctx.language = language;
if (env.err) {
Expand Down Expand Up @@ -105,7 +133,7 @@ function boot (env, language) {
if (hasBootErrors(ctx)) {
return next();
}

ctx.levels = require('../levels');
ctx.levels.translate = ctx.language.translate;

Expand Down Expand Up @@ -179,6 +207,7 @@ function boot (env, language) {
});

ctx.bus.on('data-loaded', function updatePlugins ( ) {
console.info('reloading sandbox data');
var sbx = require('../sandbox')().serverInit(env, ctx);
ctx.plugins.setProperties(sbx);
ctx.notifications.initRequests();
Expand Down Expand Up @@ -227,6 +256,7 @@ function boot (env, language) {
}

return require('bootevent')( )
.acquire(checkNode)
.acquire(checkEnv)
.acquire(augmentSettings)
.acquire(setupStorage)
Expand Down
Loading