From 86f2965c2681d682b745d0b53541096cb521d01c Mon Sep 17 00:00:00 2001 From: Timur Shemsedinov <timur.shemsedinov@gmail.com> Date: Sat, 13 Aug 2022 10:28:46 +0300 Subject: [PATCH] Exit on initializatopn timeout PR-URL: https://github.com/metarhia/impress/pull/1775 --- CHANGELOG.md | 2 ++ impress.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b13a6d5..e316f4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased][unreleased] +- Exit on initializatopn timeout + ## [3.0.0-alpha.4][] - 2022-07-30 - Fix scheduler: task id, unknown app, etc. diff --git a/impress.js b/impress.js index b3cc22ea..082e063d 100644 --- a/impress.js +++ b/impress.js @@ -42,7 +42,7 @@ const exit = async (message) => { }; const logError = (type) => (err) => { - const msg = err.stack || err.message || 'no stack trace'; + const msg = err?.stack || err?.message || 'exit'; impress.console.error(`${type}: ${msg}`); if (impress.finalization) return; if (impress.initialization) exit('Can not start Application server'); @@ -205,9 +205,10 @@ const stop = async () => { process.on('SIGINT', stop); process.on('SIGTERM', stop); - impress.startTimer = setTimeout(() => { - impress.console.warn(`Initialization timeout`); - }, config.server.timeouts.start); + impress.startTimer = setTimeout( + logError('Initialization timeout'), + config.server.timeouts.start, + ); await loadApplications();