mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-22 10:21:01 +00:00
Merge pull request #2035 from balena-os/parallel-start
Start state engine and API binder in parallel
This commit is contained in:
commit
dfcaa2ecb8
@ -59,17 +59,21 @@ export class Supervisor {
|
||||
await normaliseLegacyDatabase();
|
||||
}
|
||||
|
||||
await deviceState.loadInitialState();
|
||||
|
||||
log.info('Starting API server');
|
||||
this.api = new SupervisorAPI({
|
||||
routers: [apiBinder.router, deviceState.router],
|
||||
healthchecks: [apiBinder.healthcheck, deviceState.healthcheck],
|
||||
});
|
||||
this.api.listen(conf.listenPort, conf.apiTimeout);
|
||||
deviceState.on('shutdown', () => this.api.stop());
|
||||
|
||||
await apiBinder.start();
|
||||
// Start the state engine, the device API and API binder
|
||||
// in parallel
|
||||
await Promise.all([
|
||||
deviceState.loadInitialState(),
|
||||
(() => {
|
||||
log.info('Starting API server');
|
||||
this.api = new SupervisorAPI({
|
||||
routers: [apiBinder.router, deviceState.router],
|
||||
healthchecks: [apiBinder.healthcheck, deviceState.healthcheck],
|
||||
});
|
||||
this.api.listen(conf.listenPort, conf.apiTimeout);
|
||||
deviceState.on('shutdown', () => this.api.stop());
|
||||
})(),
|
||||
apiBinder.start(),
|
||||
]);
|
||||
|
||||
logMonitor.start();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user