fix: app quickstart (#2921)
* fix: app quickstart * fix: test * fix: test --------- Co-authored-by: Chareice <chareice@live.com>
This commit is contained in:
parent
1ff3aa94fc
commit
6f3681c2aa
@ -5,6 +5,7 @@ import compression from 'compression';
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import http, { IncomingMessage, ServerResponse } from 'http';
|
import http, { IncomingMessage, ServerResponse } from 'http';
|
||||||
|
import compose from 'koa-compose';
|
||||||
import { promisify } from 'node:util';
|
import { promisify } from 'node:util';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
@ -13,12 +14,11 @@ import { parse } from 'url';
|
|||||||
import xpipe from 'xpipe';
|
import xpipe from 'xpipe';
|
||||||
import { AppSupervisor } from '../app-supervisor';
|
import { AppSupervisor } from '../app-supervisor';
|
||||||
import { ApplicationOptions } from '../application';
|
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 { applyErrorWithArgs, getErrorWithCode } from './errors';
|
||||||
import { IPCSocketClient } from './ipc-socket-client';
|
import { IPCSocketClient } from './ipc-socket-client';
|
||||||
import { IPCSocketServer } from './ipc-socket-server';
|
import { IPCSocketServer } from './ipc-socket-server';
|
||||||
import { WSServer } from './ws-server';
|
import { WSServer } from './ws-server';
|
||||||
import compose from 'koa-compose';
|
|
||||||
|
|
||||||
const compress = promisify(compression());
|
const compress = promisify(compression());
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ export class Gateway extends EventEmitter {
|
|||||||
|
|
||||||
if (appStatus === 'initialized') {
|
if (appStatus === 'initialized') {
|
||||||
const appInstance = await AppSupervisor.getInstance().getApp(handleApp);
|
const appInstance = await AppSupervisor.getInstance().getApp(handleApp);
|
||||||
appInstance.runAsCLI(['start'], { from: 'user' });
|
appInstance.runCommand('start', '--quickstart');
|
||||||
appStatus = AppSupervisor.getInstance().getAppStatus(handleApp);
|
appStatus = AppSupervisor.getInstance().getAppStatus(handleApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ describe('multiple apps', () => {
|
|||||||
values: {
|
values: {
|
||||||
name: subAppName,
|
name: subAppName,
|
||||||
options: {
|
options: {
|
||||||
plugins: [],
|
plugins: ['nocobase'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
@ -306,7 +306,7 @@ describe('multiple apps', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await app.start();
|
await app.start();
|
||||||
await sleep(1000);
|
await sleep(5000);
|
||||||
expect(AppSupervisor.getInstance().hasApp(subAppName)).toBeTruthy();
|
expect(AppSupervisor.getInstance().hasApp(subAppName)).toBeTruthy();
|
||||||
const appStatus = AppSupervisor.getInstance().getAppStatus(subAppName);
|
const appStatus = AppSupervisor.getInstance().getAppStatus(subAppName);
|
||||||
expect(appStatus).toEqual('running');
|
expect(appStatus).toEqual('running');
|
||||||
|
@ -171,7 +171,7 @@ export class PluginMultiAppManager extends Plugin {
|
|||||||
context: options.context,
|
context: options.context,
|
||||||
});
|
});
|
||||||
|
|
||||||
const startPromise = subApp.runAsCLI(['start', '--quickstart'], { from: 'user' });
|
const startPromise = subApp.runCommand('start', '--quickstart');
|
||||||
|
|
||||||
if (options?.context?.waitSubAppInstall) {
|
if (options?.context?.waitSubAppInstall) {
|
||||||
await startPromise;
|
await startPromise;
|
||||||
@ -227,7 +227,7 @@ export class PluginMultiAppManager extends Plugin {
|
|||||||
|
|
||||||
// must skip load on upgrade
|
// must skip load on upgrade
|
||||||
if (!loadButNotStart) {
|
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)) {
|
if (!appSupervisor.hasApp(subAppInstance.name)) {
|
||||||
await AppSupervisor.getInstance().getApp(subAppInstance.name);
|
await AppSupervisor.getInstance().getApp(subAppInstance.name);
|
||||||
} else if (appSupervisor.getAppStatus(subAppInstance.name) === 'initialized') {
|
} else if (appSupervisor.getAppStatus(subAppInstance.name) === 'initialized') {
|
||||||
(await AppSupervisor.getInstance().getApp(subAppInstance.name)).runCommand('start');
|
(await AppSupervisor.getInstance().getApp(subAppInstance.name)).runCommand('start', '--quickstart');
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user