Skip to content

Commit

Permalink
Added some boot logging & allow booting using Node 14 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
sulkaharo committed Dec 9, 2020
1 parent d0cf72a commit 512139e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
51 changes: 44 additions & 7 deletions lib/server/bootevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ var UPDATE_THROTTLE = 5000;
function boot (env, language) {

function startBoot(ctx, next) {

console.log('Executing startBoot');

ctx.runtimeState = 'booting';
next();
}
Expand All @@ -27,25 +30,31 @@ function boot (env, language) {
// >= 12.6.0 does work, not recommended, will not be supported. We only support Node LTS releases
///////////////////////////////////////////////////
function checkNodeVersion (ctx, next) {

console.log('Executing checkNodeVersion');

var semver = require('semver');
var nodeVersion = process.version;

const isLTS = process.release.lts ? true : false;

if (!isLTS) {
console.log( 'ERROR: Node version ' + nodeVersion + ' is not supported. Please use a secure LTS version or upgrade your Node');
process.exit(1);
}

if (semver.satisfies(nodeVersion, '^12.0.0') || semver.satisfies(nodeVersion, '^10.0.0')) {

if (isLTS && (semver.satisfies(nodeVersion, '^14.0.0') || semver.satisfies(nodeVersion, '^12.0.0') || semver.satisfies(nodeVersion, '^10.0.0'))) {
//Latest Node 10 LTS and Node 12 LTS are recommended and supported.
//Require at least Node 8 LTS and Node 10 LTS without known security issues
console.debug('Node LTS version ' + nodeVersion + ' is supported');
next();
return;
}

console.log( 'ERROR: Node version ' + nodeVersion + ' is not supported. Please use a secure LTS version or upgrade your Node');
process.exit(1);

}

function checkEnv (ctx, next) {

console.log('Executing checkEnv');

ctx.language = language;
if (env.err) {
ctx.bootErrors = ctx.bootErrors || [ ];
Expand All @@ -59,6 +68,9 @@ function boot (env, language) {
}

function augmentSettings (ctx, next) {

console.log('Executing augmentSettings');

var configURL = env.IMPORT_CONFIG || null;
var url = require('url');
var href = null;
Expand Down Expand Up @@ -93,6 +105,8 @@ function boot (env, language) {

function checkSettings (ctx, next) {

console.log('Executing checkSettings');

ctx.bootErrors = ctx.bootErrors || [];

console.log('Checking settings');
Expand All @@ -112,6 +126,8 @@ function boot (env, language) {

function setupStorage (ctx, next) {

console.log('Executing setupStorage');

if (hasBootErrors(ctx)) {
return next();
}
Expand Down Expand Up @@ -149,6 +165,9 @@ function boot (env, language) {
}

function setupAuthorization (ctx, next) {

console.log('Executing setupAuthorization');

if (hasBootErrors(ctx)) {
return next();
}
Expand All @@ -164,6 +183,9 @@ function boot (env, language) {
}

function setupInternals (ctx, next) {

console.log('Executing setupInternals');

if (hasBootErrors(ctx)) {
return next();
}
Expand Down Expand Up @@ -214,6 +236,9 @@ function boot (env, language) {
}

function ensureIndexes (ctx, next) {

console.log('Executing ensureIndexes');

if (hasBootErrors(ctx)) {
return next();
}
Expand All @@ -230,6 +255,9 @@ function boot (env, language) {
}

function setupListeners (ctx, next) {

console.log('Executing setupListeners');

if (hasBootErrors(ctx)) {
return next();
}
Expand Down Expand Up @@ -270,6 +298,9 @@ function boot (env, language) {
}

function setupBridge (ctx, next) {

console.log('Executing setupBridge');

if (hasBootErrors(ctx)) {
return next();
}
Expand All @@ -282,6 +313,9 @@ function boot (env, language) {
}

function setupMMConnect (ctx, next) {

console.log('Executing setupMMConnect');

if (hasBootErrors(ctx)) {
return next();
}
Expand All @@ -294,6 +328,9 @@ function boot (env, language) {
}

function finishBoot (ctx, next) {

console.log('Executing finishBoot');

if (hasBootErrors(ctx)) {
return next();
}
Expand Down
3 changes: 3 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function create (app) {
}

require('./lib/server/bootevent')(env, language).boot(function booted (ctx) {

console.log('Boot event processing completed');

var app = require('./app')(env, ctx);
var server = create(app).listen(PORT, HOSTNAME);
console.log(translate('Listening on port'), PORT, HOSTNAME);
Expand Down

0 comments on commit 512139e

Please sign in to comment.