1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.onConfigUpdated = undefined;
|
7 |
|
8 | var _nightingale = require('nightingale');
|
9 |
|
10 | var _nightingale2 = _interopRequireDefault(_nightingale);
|
11 |
|
12 | var _config = require('./config');
|
13 |
|
14 | var _screen = require('./commands/screen');
|
15 |
|
16 | var screen = _interopRequireWildcard(_screen);
|
17 |
|
18 | var _display = require('./commands/display');
|
19 |
|
20 | var display = _interopRequireWildcard(_display);
|
21 |
|
22 | var _sound = require('./commands/sound');
|
23 |
|
24 | var sound = _interopRequireWildcard(_sound);
|
25 |
|
26 | var _cron = require('./cron');
|
27 |
|
28 | var _cron2 = _interopRequireDefault(_cron);
|
29 |
|
30 | var _flowRuntime = require('flow-runtime');
|
31 |
|
32 | var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
|
33 |
|
34 | 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; } }
|
35 |
|
36 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
37 |
|
38 | const logger = new _nightingale2.default('app:manager');
|
39 |
|
40 | const 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 |
|
50 | process.nextTick(() => {
|
51 | update((0, _config.get)(), true);
|
52 | });
|
53 |
|
54 | const 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 |
|
64 | function cleanExit() {
|
65 | logger.info('exiting');
|
66 | display.stop();
|
67 | process.exit(0);
|
68 | }
|
69 |
|
70 | process.on('SIGINT', cleanExit);
|
71 | process.on('SIGTERM', cleanExit);
|
72 |
|
\ | No newline at end of file |