Exit on start up errors

This commit is contained in:
D. Berge
2023-10-14 20:02:04 +02:00
parent 0e33c18b5c
commit 39a21766b6

View File

@@ -8,6 +8,7 @@ async function main () {
INFO("Running version", await version.describe());
version.compatible()
.then( (versions) => {
try {
const api = require('./api');
const ws = require('./ws');
@@ -19,12 +20,17 @@ async function main () {
const server = api.start(port, host, path);
ws.start(server);
INFO("Versions:", versions);
process.on('exit', () => eventManager.kill());
const eventManagerPath = [__dirname, "events"].join("/");
const eventManager = fork(eventManagerPath, /*{ stdio: 'ignore' }*/);
INFO("Versions:", versions);
process.on('exit', () => eventManager.kill());
} catch (err) {
ERROR(err);
process.exit(2);
}
})
.catch( ({current, wanted, component}) => {
console.error(`Fatal error: incompatible ${component} version ${current} (wanted: ${wanted})`);