mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 09:37:08 +00:00
The server will not start unless it satisfies itself that we're running against a compatible database schema.
29 lines
816 B
JavaScript
Executable File
29 lines
816 B
JavaScript
Executable File
#!/usr/bin/node
|
|
|
|
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');
|
|
|
|
const { fork } = require('child_process');
|
|
|
|
const server = api.start(process.env.HTTP_PORT || 3000, process.env.HTTP_PATH);
|
|
ws.start(server);
|
|
|
|
const eventManagerPath = [__dirname, "events"].join("/");
|
|
const eventManager = fork(eventManagerPath, /*{ stdio: 'ignore' }*/);
|
|
|
|
process.on('exit', () => eventManager.kill());
|
|
})
|
|
.catch( ({current, wanted}) => {
|
|
console.error(`Fatal error: incompatible database schema version ${current} (wanted: ${wanted})`);
|
|
process.exit(1);
|
|
});
|
|
}
|
|
|
|
main();
|