2022-10-21 14:36:49 +00:00
|
|
|
|
2022-08-16 09:45:25 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const defaultConfig = require('./config.json');
|
2022-10-21 14:36:49 +00:00
|
|
|
const DbAsync = require('./db-async');
|
2022-08-16 09:45:25 +00:00
|
|
|
|
|
|
|
const config = Object.assign({}, defaultConfig);
|
|
|
|
const localPath = path.join(__dirname, 'config.local.json');
|
|
|
|
if (fs.existsSync(localPath)) {
|
|
|
|
const localConfig = require(localPath);
|
|
|
|
Object.assign(config, localConfig);
|
|
|
|
}
|
2022-08-15 16:12:17 +00:00
|
|
|
|
2022-10-21 14:36:49 +00:00
|
|
|
let dbAsync;
|
2022-08-15 16:12:17 +00:00
|
|
|
|
|
|
|
async function main() {
|
2022-10-21 14:36:49 +00:00
|
|
|
dbAsync = new DbAsync(config)
|
|
|
|
await dbAsync.start();
|
2022-10-23 19:46:07 +00:00
|
|
|
|
2022-08-15 16:12:17 +00:00
|
|
|
process.on('SIGINT', async function() {
|
|
|
|
console.log('Got SIGINT.');
|
2022-10-23 19:46:07 +00:00
|
|
|
try {
|
|
|
|
await dbAsync.stop();
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
2022-08-15 16:12:17 +00:00
|
|
|
process.exit();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
main();
|