diff --git a/packages/core/server/src/gateway/index.ts b/packages/core/server/src/gateway/index.ts index 528ddbf4d..fd8e3f23d 100644 --- a/packages/core/server/src/gateway/index.ts +++ b/packages/core/server/src/gateway/index.ts @@ -5,6 +5,7 @@ import compression from 'compression'; import { EventEmitter } from 'events'; import fs from 'fs'; import http, { IncomingMessage, ServerResponse } from 'http'; +import compose from 'koa-compose'; import { promisify } from 'node:util'; import { resolve } from 'path'; import qs from 'qs'; @@ -13,12 +14,11 @@ import { parse } from 'url'; import xpipe from 'xpipe'; import { AppSupervisor } from '../app-supervisor'; import { ApplicationOptions } from '../application'; -import { getPackageDirByExposeUrl, getPackageNameByExposeUrl, PLUGIN_STATICS_PATH } from '../plugin-manager'; +import { PLUGIN_STATICS_PATH, getPackageDirByExposeUrl, getPackageNameByExposeUrl } from '../plugin-manager'; import { applyErrorWithArgs, getErrorWithCode } from './errors'; import { IPCSocketClient } from './ipc-socket-client'; import { IPCSocketServer } from './ipc-socket-server'; import { WSServer } from './ws-server'; -import compose from 'koa-compose'; const compress = promisify(compression()); @@ -202,7 +202,7 @@ export class Gateway extends EventEmitter { if (appStatus === 'initialized') { const appInstance = await AppSupervisor.getInstance().getApp(handleApp); - appInstance.runAsCLI(['start'], { from: 'user' }); + appInstance.runCommand('start', '--quickstart'); appStatus = AppSupervisor.getInstance().getAppStatus(handleApp); } diff --git a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/__tests__/multiple-apps.test.ts b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/__tests__/multiple-apps.test.ts index 4da6024e3..934fff93d 100644 --- a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/__tests__/multiple-apps.test.ts +++ b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/__tests__/multiple-apps.test.ts @@ -274,7 +274,7 @@ describe('multiple apps', () => { values: { name: subAppName, options: { - plugins: [], + plugins: ['nocobase'], }, }, context: { @@ -306,7 +306,7 @@ describe('multiple apps', () => { }); await app.start(); - await sleep(1000); + await sleep(5000); expect(AppSupervisor.getInstance().hasApp(subAppName)).toBeTruthy(); const appStatus = AppSupervisor.getInstance().getAppStatus(subAppName); expect(appStatus).toEqual('running'); diff --git a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts index 9b4d8d0eb..178b51a9f 100644 --- a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts @@ -171,7 +171,7 @@ export class PluginMultiAppManager extends Plugin { context: options.context, }); - const startPromise = subApp.runAsCLI(['start', '--quickstart'], { from: 'user' }); + const startPromise = subApp.runCommand('start', '--quickstart'); if (options?.context?.waitSubAppInstall) { await startPromise; @@ -227,7 +227,7 @@ export class PluginMultiAppManager extends Plugin { // must skip load on upgrade if (!loadButNotStart) { - await subApp.runCommand('start'); + await subApp.runCommand('start', '--quickstart'); } } @@ -290,7 +290,7 @@ export class PluginMultiAppManager extends Plugin { if (!appSupervisor.hasApp(subAppInstance.name)) { await AppSupervisor.getInstance().getApp(subAppInstance.name); } else if (appSupervisor.getAppStatus(subAppInstance.name) === 'initialized') { - (await AppSupervisor.getInstance().getApp(subAppInstance.name)).runCommand('start'); + (await AppSupervisor.getInstance().getApp(subAppInstance.name)).runCommand('start', '--quickstart'); } })(), );