vn-rfid/server.js

23 lines
594 B
JavaScript
Raw Normal View History

2023-01-24 09:11:58 +00:00
import stream from './src/stream.js';
import yml from 'require-yml';
import path from 'path';
import fs from 'fs-extra';
function main() {
const {pathname: root} = new URL('./', import.meta.url);
let conf = yml(path.join(root, 'config.yml'));
const localConfFile = path.join(root, 'config.local.yml');
if (fs.existsSync(localConfFile))
conf = Object.assign({}, conf, yml(localConfFile));
try {
stream(conf);
} catch (e) {
// Not working
setTimeout(main(), conf.reconnectInterval);
console.log('MAIN_ERROR', e);
}
}
main();