Update version checking mechanism.

Checks both database schema and API versions.
This commit is contained in:
D. Berge
2022-02-27 18:36:30 +01:00
parent adaa1a6b8a
commit 9aca927e49
2 changed files with 31 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ async function main () {
const version = require('./lib/version');
console.log("Running version", await version.describe());
version.compatible()
.then( () => {
.then( (versions) => {
const api = require('./api');
const ws = require('./ws');
@@ -17,10 +17,12 @@ async function main () {
const eventManagerPath = [__dirname, "events"].join("/");
const eventManager = fork(eventManagerPath, /*{ stdio: 'ignore' }*/);
console.info("Versions", versions);
process.on('exit', () => eventManager.kill());
})
.catch( ({current, wanted}) => {
console.error(`Fatal error: incompatible database schema version ${current} (wanted: ${wanted})`);
.catch( ({current, wanted, component}) => {
console.error(`Fatal error: incompatible ${component} version ${current} (wanted: ${wanted})`);
process.exit(1);
});
}