const fs = require('fs'); const path = require('path'); const defaultConfig = require('./config.json'); const MyCDC = require('./mycdc'); 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 mycdc; async function main() { mycdc = new MyCDC(config) await mycdc.start(); process.on('SIGINT', async function() { console.log('Got SIGINT.'); try { await mycdc.stop(); } catch (err) { console.error(err); } process.exit(); }); } main();