fix(app-supervisor): wrong logic in app init (#1489)

This causes to return `initializating` when even accessing a non-existed app for the first time.

Reviewed-on: daoyoucloud/tachybase#1489
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: TomyJan <TomyJan6@gmail.com>
Co-committed-by: TomyJan <TomyJan6@gmail.com>
This commit is contained in:
TomyJan 2024-08-27 16:57:11 +08:00 committed by sealday
parent 6b9e9624eb
commit b283363da3
2 changed files with 4 additions and 6 deletions

View File

@ -127,7 +127,9 @@ export class AppSupervisor extends EventEmitter implements AsyncEmitter {
async bootStrapApp(appName: string, options = {}) {
await this.getMutexOfApp(appName).runExclusive(async () => {
if (!this.hasApp(appName)) {
this.setAppStatus(appName, 'initializing');
if (!this.getAppStatus(appName)) {
this.setAppStatus(appName, 'initializing');
}
if (this.appBootstrapper) {
await this.appBootstrapper({

View File

@ -219,11 +219,7 @@ export class Gateway extends EventEmitter {
const handleApp = await this.getRequestHandleAppName(req as IncomingRequest);
const log = this.getLogger(handleApp, res);
const hasApp = AppSupervisor.getInstance().hasApp(handleApp);
if (!hasApp) {
void AppSupervisor.getInstance().bootStrapApp(handleApp);
}
await AppSupervisor.getInstance().getApp(handleApp);
let appStatus = AppSupervisor.getInstance().getAppStatus(handleApp, 'initializing');