29 lines
606 B
JavaScript
29 lines
606 B
JavaScript
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const defaultConfig = require('./config.json');
|
|
const DbAsync = require('./db-async');
|
|
|
|
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);
|
|
}
|
|
|
|
let dbAsync;
|
|
|
|
async function main() {
|
|
|
|
dbAsync = new DbAsync(config)
|
|
await dbAsync.start();
|
|
|
|
process.on('SIGINT', async function() {
|
|
console.log('Got SIGINT.');
|
|
await dbAsync.stop();
|
|
process.exit();
|
|
});
|
|
}
|
|
|
|
main();
|