mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 08:25:36 +00:00
Start state engine and API binder in parallel
The state engine and preloading is performed before the device gets a chance to register, while this is desirable for preloaded apps, it introduces a delay on registration which is known to cause issues since the VPN is also trying to connect at the same time. This triggers a simultaneous start of the device engine, the API binder and the supevisor API to avoid delays. Change-type: patch
This commit is contained in:
parent
ef0dcc39dc
commit
b4514631b1
@ -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