Merge pull request 'improved initialization' (#61) from develop into master
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #61
This commit is contained in:
commit
0c609261d7
1 changed files with 5 additions and 7 deletions
|
@ -60,19 +60,17 @@ const serviceStatePaths: { [service: string]: string } = config.groups
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
let cache: CurrentStatus;
|
let cache: CurrentStatus;
|
||||||
let uptimeStates = existsSync(join(process.cwd(), 'uptime.json')) ? JSON.parse(readFileSync(join(process.cwd(), 'uptime.json'), {encoding: 'utf-8'})) : null as { [id: string]: UptimeStatus; };
|
let uptimeStates = existsSync(join(process.cwd(), 'uptime.json')) ? JSON.parse(readFileSync(join(process.cwd(), 'uptime.json'), {encoding: 'utf-8'})) : {} as { [id: string]: UptimeStatus; };
|
||||||
|
// init serviceStates and uptimeStates
|
||||||
config.groups
|
config.groups
|
||||||
.map(g => g.services).reduce((x, y) => x.concat(y), [])
|
.map(g => g.services).reduce((x, y) => x.concat(y), [])
|
||||||
.map(s => s.id).filter(id => !serviceStates[id])
|
.map(s => s.id).filter(id => !serviceStates[id])
|
||||||
.forEach(id => serviceStates[id] = 'operational');
|
.forEach(id => serviceStates[id] = 'operational');
|
||||||
if (!uptimeStates) {
|
|
||||||
uptimeStates = {};
|
|
||||||
for (let id in serviceStates) {
|
for (let id in serviceStates) {
|
||||||
if (serviceStates.hasOwnProperty(id)) {
|
if (serviceStates.hasOwnProperty(id)) {
|
||||||
updateServiceState(id, serviceStates[id]);
|
updateServiceState(id, serviceStates[id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
updateCache();
|
updateCache();
|
||||||
|
|
||||||
api.post('/update/health', (req, res) => {
|
api.post('/update/health', (req, res) => {
|
||||||
|
|
Reference in a new issue