fix: app manager reload (#1565)
* fix: app manager reload * chore: plugin test order
This commit is contained in:
parent
9c60402153
commit
e86e40b93a
@ -33,6 +33,9 @@ export function getConfigByEnv() {
|
||||
timezone: process.env.DB_TIMEZONE,
|
||||
underscored: process.env.DB_UNDERSCORED === 'true',
|
||||
schema: process.env.DB_SCHEMA !== 'public' ? process.env.DB_SCHEMA : undefined,
|
||||
dialectOptions: {
|
||||
application_name: process.env.DB_DIALECT == 'postgres' ? 'nocobase.main' : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,17 @@ type AppSelector = (req: IncomingMessage) => AppSelectorReturn | Promise<AppSele
|
||||
|
||||
export class AppManager extends EventEmitter {
|
||||
public applications: Map<string, Application> = new Map<string, Application>();
|
||||
public app: Application;
|
||||
|
||||
constructor(public app: Application) {
|
||||
constructor(app: Application) {
|
||||
super();
|
||||
this.bindMainApplication(app);
|
||||
}
|
||||
|
||||
bindMainApplication(mainApp: Application) {
|
||||
this.app = mainApp;
|
||||
const passEventToSubApps = (eventName, method) => {
|
||||
app.on(eventName, async (mainApp, options) => {
|
||||
mainApp.on(eventName, async (mainApp, options) => {
|
||||
console.log(`receive event ${eventName} from ${mainApp.name}`);
|
||||
for (const application of this.applications.values()) {
|
||||
console.log(`pass ${eventName} to ${application.name} `);
|
||||
|
@ -271,7 +271,11 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
});
|
||||
}
|
||||
|
||||
this._appManager = new AppManager(this);
|
||||
if (this._appManager) {
|
||||
this._appManager.bindMainApplication(this);
|
||||
} else {
|
||||
this._appManager = new AppManager(this);
|
||||
}
|
||||
|
||||
if (this.options.acl !== false) {
|
||||
this._resourcer.use(this._acl.middleware(), { tag: 'acl', after: ['parseToken'] });
|
||||
|
@ -90,7 +90,7 @@ pgOnly()('collection sync', () => {
|
||||
expect(userInSub2.get('roles').map((item) => item.name)).toContain(defaultRoleInSub2.name);
|
||||
});
|
||||
|
||||
it.skip('should sync plugin status between apps', async () => {
|
||||
it('should sync plugin status between apps', async () => {
|
||||
await mainApp.db.getRepository('applications').create({
|
||||
values: {
|
||||
name: 'sub1',
|
||||
|
@ -1,5 +1,6 @@
|
||||
import PluginMultiAppManager from '@nocobase/plugin-multi-app-manager';
|
||||
import { Application, InstallOptions, Plugin } from '@nocobase/server';
|
||||
import lodash from 'lodash';
|
||||
|
||||
const subAppFilteredPlugins = ['multi-app-share-collection', 'multi-app-manager'];
|
||||
|
||||
@ -241,7 +242,11 @@ export class MultiAppShareCollectionPlugin extends Plugin {
|
||||
);
|
||||
|
||||
return {
|
||||
database: databaseOptions,
|
||||
database: lodash.merge(databaseOptions, {
|
||||
dialectOptions: {
|
||||
application_name: `nocobase.${appName}`,
|
||||
},
|
||||
}),
|
||||
plugins: plugins.includes('nocobase') ? ['nocobase'] : plugins,
|
||||
resourcer: {
|
||||
prefix: '/api',
|
||||
|
Loading…
Reference in New Issue
Block a user