UNPKG

1.98 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.onConfigUpdated = undefined;
7
8var _nightingale = require('nightingale');
9
10var _nightingale2 = _interopRequireDefault(_nightingale);
11
12var _config = require('./config');
13
14var _screen = require('./commands/screen');
15
16var screen = _interopRequireWildcard(_screen);
17
18var _display = require('./commands/display');
19
20var display = _interopRequireWildcard(_display);
21
22var _sound = require('./commands/sound');
23
24var sound = _interopRequireWildcard(_sound);
25
26var _cron = require('./cron');
27
28var _cron2 = _interopRequireDefault(_cron);
29
30var _flowRuntime = require('flow-runtime');
31
32var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
33
34function _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; } }
35
36function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
38const logger = new _nightingale2.default('app:manager');
39
40const update = (config, firstTime = false) => {
41 let _configType = _flowRuntime2.default.object();
42
43 _flowRuntime2.default.param('config', _configType).assert(config);
44
45 (0, _cron2.default)(config);
46 screen.update(config, firstTime);
47 sound.update(config);
48};
49
50process.nextTick(() => {
51 update((0, _config.get)(), true);
52});
53
54const onConfigUpdated = exports.onConfigUpdated = newConfig => {
55 let _newConfigType = _flowRuntime2.default.object();
56
57 _flowRuntime2.default.param('newConfig', _newConfigType).assert(newConfig);
58
59 logger.info('config updated');
60 if (!(0, _config.updateConfig)(newConfig)) return;
61 update(newConfig);
62};
63
64function cleanExit() {
65 logger.info('exiting');
66 display.stop();
67 process.exit(0);
68}
69
70process.on('SIGINT', cleanExit);
71process.on('SIGTERM', cleanExit);
72//# sourceMappingURL=manager.js.map
\No newline at end of file