UNPKG

pooliot-client

Version:
37 lines (30 loc) 948 B
import Logger from 'nightingale'; import { updateConfig, get as getConfig } from './config'; import * as screen from './commands/screen'; import * as display from './commands/display'; import * as sound from './commands/sound'; import * as system from './commands/system'; import updateCronTasks from './cron'; const logger = new Logger('app:manager'); const update = (config: Object, firstTime = false) => { updateCronTasks(config); screen.update(config, firstTime); sound.update(config); }; process.nextTick(() => { // update time (can fix some SSL certificate issues) system.ntpUpdate(); update(getConfig(), true); }); export const onConfigUpdated = (newConfig: Object) => { logger.info('config updated'); if (!updateConfig(newConfig)) return; update(newConfig); }; function cleanExit() { logger.info('exiting'); display.stop(); process.exit(0); } process.on('SIGINT', cleanExit); process.on('SIGTERM', cleanExit);