fix(multi-app-manager): sub-app asynchronous quick start (#5571)

This commit is contained in:
chenos 2024-11-03 17:09:12 +08:00 committed by GitHub
parent 08ce9fa923
commit 17582e9351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,10 @@ import lodash from 'lodash';
import path from 'path';
import { ApplicationModel } from '../server';
export type AppDbCreator = (app: Application, options?: Transactionable & { context?: any }) => Promise<void>;
export type AppDbCreator = (
app: Application,
options?: Transactionable & { context?: any; applicationModel?: ApplicationModel },
) => Promise<void>;
export type AppOptionsFactory = (appName: string, mainApp: Application) => any;
export type SubAppUpgradeHandler = (mainApp: Application) => Promise<void>;
@ -189,17 +192,22 @@ export class PluginMultiAppManagerServer extends Plugin {
appOptionsFactory: this.appOptionsFactory,
});
// create database
await this.appDbCreator(subApp, {
transaction,
context: options.context,
});
const quickstart = async () => {
// create database
await this.appDbCreator(subApp, {
transaction,
applicationModel: model,
context: options.context,
});
const startPromise = subApp.runCommand('start', '--quickstart');
const startPromise = subApp.runCommand('start', '--quickstart');
if (options?.context?.waitSubAppInstall) {
await startPromise;
}
if (options?.context?.waitSubAppInstall) {
await startPromise;
}
};
quickstart();
},
);