Skip to content
Snippets Groups Projects
Commit ea44ebdb authored by Guilherme Gazzo's avatar Guilherme Gazzo
Browse files

move apps initialize to run after license runs

parent ff8716a8
No related tags found
No related merge requests found
......@@ -30,9 +30,6 @@ function isTesting() {
const DISABLED_PRIVATE_APP_INSTALLATION = ['yes', 'true'].includes(String(process.env.DISABLE_PRIVATE_APP_INSTALLATION).toLowerCase());
let appsSourceStorageType;
let appsSourceStorageFilesystemPath;
export class AppServerOrchestrator {
constructor() {
this._isInitialized = false;
......@@ -56,7 +53,10 @@ export class AppServerOrchestrator {
this._persistModel = AppsPersistence;
this._storage = new AppRealStorage(this._model);
this._logStorage = new AppRealLogStorage(this._logModel);
this._appSourceStorage = new ConfigurableAppSourceStorage(appsSourceStorageType, appsSourceStorageFilesystemPath);
this._appSourceStorage = new ConfigurableAppSourceStorage(
settings.get('Apps_Framework_Source_Package_Storage_Type'),
settings.get('Apps_Framework_Source_Package_Storage_FileSystem_Path'),
);
this._converters = new Map();
this._converters.set('messages', new AppMessagesConverter(this));
......@@ -256,19 +256,3 @@ export class AppServerOrchestrator {
export const Apps = new AppServerOrchestrator();
registerOrchestrator(Apps);
settings.watch('Apps_Framework_Source_Package_Storage_Type', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageType = value;
} else {
Apps.getAppSourceStorage().setStorage(value);
}
});
settings.watch('Apps_Framework_Source_Package_Storage_FileSystem_Path', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageFilesystemPath = value;
} else {
Apps.getAppSourceStorage().setFileSystemStoragePath(value);
}
});
import { Meteor } from 'meteor/meteor';
import { License } from '@rocket.chat/license';
import { Apps } from './orchestrator';
import { settings, settingsRegistry } from '../../../app/settings/server';
import { disableAppsWithAddonsCallback } from '../lib/apps/disableAppsWithAddonsCallback';
Meteor.startup(async function _appServerOrchestrator() {
export const startupApp = async function startupApp() {
await settingsRegistry.addGroup('General', async function () {
await this.section('Apps', async function () {
await this.add('Apps_Logs_TTL', '30_days', {
......@@ -56,11 +57,22 @@ Meteor.startup(async function _appServerOrchestrator() {
});
});
async function migratePrivateAppsCallback() {
void Apps.migratePrivateApps();
void Apps.disableMarketplaceApps();
}
License.onInvalidateLicense(migratePrivateAppsCallback);
License.onRemoveLicense(migratePrivateAppsCallback);
// Disable apps that depend on add-ons (external modules) if they are invalidated
License.onModule(disableAppsWithAddonsCallback);
settings.watch('Apps_Logs_TTL', async (value) => {
// TODO: remove this feature, initialized is always false first time
if (!Apps.isInitialized()) {
return;
}
let expireAfterSeconds = 0;
switch (value) {
......@@ -80,11 +92,18 @@ Meteor.startup(async function _appServerOrchestrator() {
}
const model = Apps._logModel;
await model!.resetTTLIndex(expireAfterSeconds);
});
Apps.initialize();
void Apps.load();
});
settings.change<'filesystem' | 'gridfs'>('Apps_Framework_Source_Package_Storage_Type', (value) =>
Apps.getAppSourceStorage()!.setStorage(value),
);
settings.change<string>('Apps_Framework_Source_Package_Storage_FileSystem_Path', (value) =>
Apps.getAppSourceStorage()!.setFileSystemStoragePath(value),
);
};
......@@ -12,7 +12,7 @@ import './requestSeatsRoute';
import './configuration/index';
import './local-services/ldap/service';
import './methods/getReadReceipts';
import './apps/startup';
import './patches';
export * from './apps/startup';
export { registerEEBroker } from './startup';
import { License } from '@rocket.chat/license';
import { Meteor } from 'meteor/meteor';
import { Apps } from '../apps';
import { disableAppsWithAddonsCallback } from '../lib/apps/disableAppsWithAddonsCallback';
Meteor.startup(() => {
async function migratePrivateAppsCallback() {
if (!Apps.isInitialized) return;
void Apps.migratePrivateApps();
void Apps.disableMarketplaceApps();
}
License.onInvalidateLicense(migratePrivateAppsCallback);
License.onRemoveLicense(migratePrivateAppsCallback);
// Disable apps that depend on add-ons (external modules) if they are invalidated
License.onModule(disableAppsWithAddonsCallback);
});
import '../../app/authorization/server';
import './apps';
import './audit';
import './deviceManagement';
import './engagementDashboard';
......
......@@ -11,6 +11,7 @@ import { configureServer } from './configuration';
import { registerServices } from './services/startup';
import { startup } from './startup';
import { settings } from '../app/settings/server';
import { startupApp } from '../ee/server';
import { startRocketChat } from '../startRocketChat';
import './routes';
......@@ -25,3 +26,4 @@ import './features/EmailInbox/index';
await Promise.all([configureServer(settings), registerServices(), startup()]);
await startRocketChat();
await startupApp();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment