server: Perform init after adding uncaught exception handler
This avoids an unnecessary `try` block.pull/4656/head
parent
86ceb2b610
commit
d339f2a671
|
@ -60,22 +60,6 @@ exports.start = async () => {
|
|||
stats.gauge('memoryUsage', () => process.memoryUsage().rss);
|
||||
stats.gauge('memoryUsageHeap', () => process.memoryUsage().heapUsed);
|
||||
|
||||
await util.promisify(npm.load)();
|
||||
|
||||
try {
|
||||
await db.init();
|
||||
await plugins.update();
|
||||
console.info(`Installed plugins: ${plugins.formatPluginsWithVersion()}`);
|
||||
console.debug(`Installed parts:\n${plugins.formatParts()}`);
|
||||
console.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
||||
await hooks.aCallAll('loadSettings', {settings});
|
||||
await hooks.aCallAll('createServer');
|
||||
} catch (e) {
|
||||
console.error(`exception thrown: ${e.message}`);
|
||||
if (e.stack) console.log(e.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.on('uncaughtException', exports.exit);
|
||||
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
|
||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||
|
@ -105,6 +89,15 @@ exports.start = async () => {
|
|||
// Pass undefined to exports.exit because this is not an abnormal termination.
|
||||
process.on('SIGTERM', () => exports.exit());
|
||||
|
||||
await util.promisify(npm.load)();
|
||||
await db.init();
|
||||
await plugins.update();
|
||||
console.info(`Installed plugins: ${plugins.formatPluginsWithVersion()}`);
|
||||
console.debug(`Installed parts:\n${plugins.formatParts()}`);
|
||||
console.debug(`Installed hooks:\n${plugins.formatHooks()}`);
|
||||
await hooks.aCallAll('loadSettings', {settings});
|
||||
await hooks.aCallAll('createServer');
|
||||
|
||||
// Return the HTTP server to make it easier to write tests.
|
||||
return express.server;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue