2020-09-13 15:35:36 +02:00
|
|
|
#!/usr/bin/node
|
2020-08-08 23:59:13 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
async function main () {
|
|
|
|
|
// Check that we're running against the correct database version
|
|
|
|
|
const version = require('./lib/version');
|
|
|
|
|
console.log("Running version", await version.describe());
|
|
|
|
|
version.compatible()
|
|
|
|
|
.then( () => {
|
|
|
|
|
const api = require('./api');
|
|
|
|
|
const ws = require('./ws');
|
2020-10-02 01:34:49 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
const { fork } = require('child_process');
|
2020-10-02 01:34:49 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
const server = api.start(process.env.HTTP_PORT || 3000, process.env.HTTP_PATH);
|
|
|
|
|
ws.start(server);
|
2020-08-08 23:59:13 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
const eventManagerPath = [__dirname, "events"].join("/");
|
|
|
|
|
const eventManager = fork(eventManagerPath, /*{ stdio: 'ignore' }*/);
|
2020-10-02 01:34:49 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
process.on('exit', () => eventManager.kill());
|
|
|
|
|
})
|
|
|
|
|
.catch( ({current, wanted}) => {
|
|
|
|
|
console.error(`Fatal error: incompatible database schema version ${current} (wanted: ${wanted})`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-10-02 01:34:49 +02:00
|
|
|
|
2022-02-06 22:52:45 +01:00
|
|
|
main();
|