mycdc/index.js

31 lines
651 B
JavaScript
Raw Normal View History

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-24 06:01:43 +00:00
const MyCDC = require('./mycdc');
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-24 06:01:43 +00:00
let mycdc;
2022-08-15 16:12:17 +00:00
async function main() {
2022-10-24 06:01:43 +00:00
mycdc = new MyCDC(config)
await mycdc.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 {
2022-10-24 06:01:43 +00:00
await mycdc.stop();
2022-10-23 19:46:07 +00:00
} catch (err) {
console.error(err);
}
2022-08-15 16:12:17 +00:00
process.exit();
});
}
main();