vn-rfid/server.js

22 lines
622 B
JavaScript
Raw Normal View History

2023-01-24 09:11:58 +00:00
import stream from './src/stream.js';
2023-01-24 14:10:39 +00:00
import getConfig from './util/getConfig.js';
import logger from 'pino';
2023-05-02 08:23:07 +00:00
import getArcs from './db/querys/getArcs.js';
2023-01-24 14:10:39 +00:00
console.logger = logger();
2023-01-24 09:11:58 +00:00
2023-05-02 08:23:07 +00:00
async function main(arcId) {
2023-01-24 14:10:39 +00:00
const conf = getConfig();
2023-05-02 08:23:07 +00:00
for (let arc of await getArcs()) {
const config = Object.assign({}, conf, arc);
if (arcId && arcId != arc.arcId) continue;
console.logger.info(`ARC_ID:${config.arcId} is running...`);
2023-05-02 08:23:07 +00:00
stream(config, e => {
console.logger.error(e);
setTimeout(main, config.reconnectInterval, config.arcId);
});
}
2023-01-24 09:11:58 +00:00
}
main();