pooliot-client
Version:
30 lines (24 loc) • 839 B
JavaScript
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);
};
export const cleanExit = () => display.stop();