pooliot-client
Version:
78 lines (50 loc) • 2.15 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.onConfigUpdated = undefined;
var _nightingale = require('nightingale');
var _nightingale2 = _interopRequireDefault(_nightingale);
var _config = require('./config');
var _screen = require('./commands/screen');
var screen = _interopRequireWildcard(_screen);
var _display = require('./commands/display');
var display = _interopRequireWildcard(_display);
var _sound = require('./commands/sound');
var sound = _interopRequireWildcard(_sound);
var _system = require('./commands/system');
var system = _interopRequireWildcard(_system);
var _cron = require('./cron');
var _cron2 = _interopRequireDefault(_cron);
var _flowRuntime = require('flow-runtime');
var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const logger = new _nightingale2.default('app:manager');
const update = (config, firstTime = false) => {
let _configType = _flowRuntime2.default.object();
_flowRuntime2.default.param('config', _configType).assert(config);
(0, _cron2.default)(config);
screen.update(config, firstTime);
sound.update(config);
};
process.nextTick(() => {
// update time (can fix some SSL certificate issues)
system.ntpUpdate();
update((0, _config.get)(), true);
});
const onConfigUpdated = exports.onConfigUpdated = newConfig => {
let _newConfigType = _flowRuntime2.default.object();
_flowRuntime2.default.param('newConfig', _newConfigType).assert(newConfig);
logger.info('config updated');
if (!(0, _config.updateConfig)(newConfig)) return;
update(newConfig);
};
function cleanExit() {
logger.info('exiting');
display.stop();
process.exit(0);
}
process.on('SIGINT', cleanExit);
process.on('SIGTERM', cleanExit);
//# sourceMappingURL=manager.js.map
;