Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Startup Time #23210

Merged
merged 92 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
e90a8d9
Change setting init
ggazzo Sep 15, 2021
0896860
WIP
ggazzo Sep 23, 2021
422b32a
move permission creation
ggazzo Sep 23, 2021
96ed60e
Fix lint
ggazzo Sep 23, 2021
2b59d13
Fix TS
sampaiodiego Sep 23, 2021
dd468b1
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Sep 23, 2021
ee44aec
prevent upsert groups
ggazzo Sep 23, 2021
fa2787f
Fix typings
sampaiodiego Sep 23, 2021
af51205
Improve test stored value
sampaiodiego Sep 23, 2021
7110ddf
Revert cron
sampaiodiego Sep 23, 2021
f187470
Move init to constructor
sampaiodiego Sep 23, 2021
cf38034
Remove async
sampaiodiego Sep 23, 2021
06afad9
Remove federation cron files
sampaiodiego Sep 23, 2021
6aafc9d
Type validation
ggazzo Sep 23, 2021
4895223
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Sep 23, 2021
ffb5b95
fix startup from zero
ggazzo Sep 23, 2021
c34b5d8
fix merge
ggazzo Sep 23, 2021
7b2e6a7
TIREI O ENTER
ggazzo Sep 23, 2021
d55f212
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
ggazzo Sep 23, 2021
1ff9158
Force Init
ggazzo Sep 23, 2021
0ed6669
Startup
ggazzo Sep 24, 2021
86dbfdf
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
ggazzo Sep 24, 2021
ab7330d
Fix LDAP merge
ggazzo Sep 24, 2021
cf461ec
..
ggazzo Sep 24, 2021
79a87ad
....
ggazzo Sep 24, 2021
50d6113
OMG
ggazzo Sep 24, 2021
583b50c
skip
ggazzo Sep 24, 2021
f888670
Testing new Setting helpers
ggazzo Sep 24, 2021
312432e
Improve unit test
ggazzo Sep 24, 2021
12be33e
Move get from watch
ggazzo Sep 24, 2021
28ca6ef
Fix watch with keys
ggazzo Sep 24, 2021
d14b348
do not emit if there is no change
ggazzo Sep 24, 2021
4465045
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
ggazzo Sep 24, 2021
7167d30
Lint
ggazzo Sep 24, 2021
aa6c950
improve startup
ggazzo Sep 24, 2021
bb3980e
.
ggazzo Sep 24, 2021
870fd49
console.log
ggazzo Sep 24, 2021
19bc934
.
ggazzo Sep 24, 2021
d289ee7
DID
ggazzo Sep 24, 2021
40e28e5
.
ggazzo Sep 25, 2021
2b2682e
..
ggazzo Sep 25, 2021
494421c
DID 2.0
ggazzo Sep 25, 2021
fd8c470
fix
ggazzo Sep 25, 2021
203f331
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Sep 25, 2021
6d3c9fe
done
ggazzo Sep 25, 2021
ab67693
Change logs
ggazzo Sep 27, 2021
2d38af6
Created middleware to wrap debounced functions
ggazzo Sep 29, 2021
53e1a8f
Merge remote-tracking branch 'origin/develop' into chore/startup-perf…
ggazzo Sep 29, 2021
19e6890
Remove Meteor.bind
ggazzo Sep 30, 2021
39cb034
improve use middleware
ggazzo Sep 30, 2021
9232930
.
ggazzo Sep 30, 2021
f769a7b
..
ggazzo Sep 30, 2021
13ebb7e
...
ggazzo Sep 30, 2021
038c1e0
Merge remote-tracking branch 'origin/develop' into chore/startup-perf…
ggazzo Oct 2, 2021
111b482
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
ggazzo Oct 11, 2021
db377e6
Apply suggestions from code review
ggazzo Oct 11, 2021
d815671
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Oct 11, 2021
bbfdac8
Fix review
ggazzo Oct 11, 2021
91b8bc0
Replaced old setttings over new settings
ggazzo Oct 13, 2021
5330d9a
Fix lint
ggazzo Oct 13, 2021
7e5540b
..
ggazzo Oct 13, 2021
ad620e6
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Oct 13, 2021
59f2732
fix typings
ggazzo Oct 13, 2021
26c0c1e
..
ggazzo Oct 13, 2021
df32c25
noss
ggazzo Oct 13, 2021
1a855aa
Unit test
ggazzo Oct 13, 2021
2386857
fix lint
ggazzo Oct 14, 2021
27aa531
fix SettingsEvents
ggazzo Oct 14, 2021
ef9020f
fix updateValue middleare
ggazzo Oct 14, 2021
0c5a974
Merge branch 'develop' into chore/startup-performance
sampaiodiego Oct 14, 2021
4e70224
fix Review
ggazzo Oct 15, 2021
610daf0
Fix review
ggazzo Oct 15, 2021
9ba590e
Merge branch 'develop' into chore/startup-performance
ggazzo Oct 15, 2021
eab14c0
...
ggazzo Oct 15, 2021
aba2105
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
ggazzo Oct 15, 2021
b7e1d67
fix client
ggazzo Oct 15, 2021
0c9b1bb
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
sampaiodiego Oct 15, 2021
61a882f
fix
ggazzo Oct 15, 2021
31dd7d8
..
ggazzo Oct 15, 2021
0b9e436
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
sampaiodiego Oct 15, 2021
69b51ad
Merge remote-tracking branch 'origin/develop' into chore/startup-perf…
ggazzo Oct 19, 2021
c94ad53
Fix Review
ggazzo Oct 19, 2021
3971d59
improve comparision
ggazzo Oct 19, 2021
95a2697
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
sampaiodiego Oct 19, 2021
ae3d2df
fix unit test
ggazzo Oct 19, 2021
f955f2b
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
sampaiodiego Oct 19, 2021
f3a264c
Renames
ggazzo Oct 19, 2021
c967463
did
ggazzo Oct 19, 2021
9d29bd0
didi2
ggazzo Oct 19, 2021
abc787a
Merge branch 'chore/startup-performance' of github.com:RocketChat/Roc…
sampaiodiego Oct 19, 2021
c2f5203
isEqual
sampaiodiego Oct 19, 2021
289a8df
Fix update
sampaiodiego Oct 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/2fa/server/lib/totp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Random } from 'meteor/random';
import speakeasy from 'speakeasy';

import { Users } from '../../../models';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';

export const TOTP = {
generateSecret() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';

settings.addGroup('Accounts', function() {
settingsRegistry.addGroup('Accounts', function() {
this.section('Two Factor Authentication', function() {
const enable2FA = {
_id: 'Accounts_TwoFactorAuthentication_Enabled',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';

settings.addGroup('Analytics', function addSettings() {
settingsRegistry.addGroup('Analytics', function addSettings() {
this.section('Piwik', function() {
const enableQuery = { _id: 'PiwikAnalytics_enabled', value: true };
this.add('PiwikAnalytics_enabled', false, {
Expand Down
10 changes: 5 additions & 5 deletions app/api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,11 @@ const createApis = function _createApis() {
createApis();

// register the API to be re-created once the CORS-setting changes.
settings.get(/^(API_Enable_CORS|API_CORS_Origin)$/, () => {
settings.watchMultiple(['API_Enable_CORS', 'API_CORS_Origin'], () => {
createApis();
});

settings.get('Accounts_CustomFields', (key, value) => {
settings.watch('Accounts_CustomFields', (value) => {
if (!value) {
return API.v1.setLimitedCustomFields([]);
}
Expand All @@ -761,16 +761,16 @@ settings.get('Accounts_CustomFields', (key, value) => {
}
});

settings.get('API_Enable_Rate_Limiter_Limit_Time_Default', (key, value) => {
settings.watch('API_Enable_Rate_Limiter_Limit_Time_Default', (value) => {
defaultRateLimiterOptions.intervalTimeInMS = value;
API.v1.reloadRoutesToRefreshRateLimiter();
});

settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default', (key, value) => {
settings.watch('API_Enable_Rate_Limiter_Limit_Calls_Default', (value) => {
defaultRateLimiterOptions.numRequestsAllowed = value;
API.v1.reloadRoutesToRefreshRateLimiter();
});

settings.get('Prometheus_API_User_Agent', (key, value) => {
settings.watch('Prometheus_API_User_Agent', (value) => {
prometheusAPIUserAgent = value;
});
2 changes: 1 addition & 1 deletion app/api/server/helpers/getPaginationItems.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// If the count query param is higher than the "API_Upper_Count_Limit" setting, then we limit that
// If the count query param isn't defined, then we set it to the "API_Default_Count" setting
// If the count is zero, then that means unlimited and is only allowed if the setting "API_Allow_Infinite_Count" is true
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { API } from '../api';

API.helperMethods.set('getPaginationItems', function _getPaginationItems() {
Expand Down
6 changes: 3 additions & 3 deletions app/api/server/helpers/getUserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ API.helperMethods.set('getUserInfo', function _getUserInfo(me) {
};
const getUserPreferences = () => {
const defaultUserSettingPrefix = 'Accounts_Default_User_Preferences_';
const allDefaultUserSettings = settings.get(new RegExp(`^${ defaultUserSettingPrefix }.*$`));
const allDefaultUserSettings = settings.getByRegexp(new RegExp(`^${ defaultUserSettingPrefix }.*$`));

return allDefaultUserSettings.reduce((accumulator, setting) => {
const settingWithoutPrefix = setting.key.replace(defaultUserSettingPrefix, ' ').trim();
return allDefaultUserSettings.reduce((accumulator, [key]) => {
const settingWithoutPrefix = key.replace(defaultUserSettingPrefix, ' ').trim();
accumulator[settingWithoutPrefix] = getUserPreference(me, settingWithoutPrefix);
return accumulator;
}, {});
Expand Down
4 changes: 2 additions & 2 deletions app/api/server/settings.js → app/api/server/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';

settings.addGroup('General', function() {
settingsRegistry.addGroup('General', function() {
this.section('REST API', function() {
this.add('API_Upper_Count_Limit', 100, { type: 'int', public: false });
this.add('API_Default_Count', 50, { type: 'int', public: false });
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/autotranslate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { API } from '../api';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Messages } from '../../../models/server';

API.v1.addRoute('autotranslate.getSupportedLanguages', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { API } from '../api';
import Rooms from '../../../models/server/models/Rooms';
import Users from '../../../models/server/models/Users';
import Subscriptions from '../../../models/server/models/Subscriptions';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { findMentionedMessages, findStarredMessages, findSnippetedMessageById, findSnippetedMessages, findDiscussionsFromRoom } from '../lib/messages';

API.v1.addRoute('chat.delete', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API.v1.addRoute('ldap.testConnection', { authRequired: true }, {
throw new Error('error-not-authorized');
}

if (settings.get('LDAP_Enable') !== true) {
if (settings.get<boolean>('LDAP_Enable') !== true) {
throw new Error('LDAP_disabled');
}

Expand Down
5 changes: 1 addition & 4 deletions app/api/server/v1/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ API.v1.addRoute('settings/:_id', { authRequired: true }, {
value: Match.Any,
});
if (Settings.updateValueNotHiddenById(this.urlParams._id, this.bodyParams.value)) {
settings.storeSettingValue({
_id: this.urlParams._id,
value: this.bodyParams.value,
});
settings.set(Settings.findOneNotHiddenById(this.urlParams._id));
setValue(this.urlParams._id, this.bodyParams.value);
return API.v1.success();
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import _ from 'underscore';
import { Users, Subscriptions } from '../../../models/server';
import { Users as UsersRaw } from '../../../models/server/raw';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { getURL } from '../../../utils';
import {
validateCustomFields,
Expand Down
2 changes: 1 addition & 1 deletion app/apple/server/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import './startup.js';
import './startup';
import './loginHandler.js';
17 changes: 5 additions & 12 deletions app/apple/server/startup.js → app/apple/server/startup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';

import { settings } from '../../settings';
import { settings, settingsRegistry } from '../../settings/server';

settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('Apple', function() {
this.add('Accounts_OAuth_Apple', false, { type: 'boolean', public: true });
});
});

const configureService = _.debounce(Meteor.bindEnvironment(() => {
if (!settings.get('Accounts_OAuth_Apple')) {

settings.watch('Accounts_OAuth_Apple', (enabled) => {
if (!enabled) {
return ServiceConfiguration.configurations.remove({
service: 'apple',
});
Expand All @@ -26,10 +25,4 @@ const configureService = _.debounce(Meteor.bindEnvironment(() => {
enabled: settings.get('Accounts_OAuth_Apple'),
},
});
}), 1000);

Meteor.startup(() => {
settings.get('Accounts_OAuth_Apple', () => {
configureService();
});
});
4 changes: 3 additions & 1 deletion app/apps/client/orchestrator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AppClientManager } from '@rocket.chat/apps-engine/client/AppClientManager';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { dispatchToastMessage } from '../../../client/lib/toast';
import { hasAtLeastOnePermission } from '../../authorization';
Expand Down Expand Up @@ -192,7 +193,8 @@ Meteor.startup(() => {
});
});

settings.get('Apps_Framework_enabled', (isEnabled) => {
Tracker.autorun(() => {
const isEnabled = settings.get('Apps_Framework_enabled');
Apps.load(isEnabled);
});
});
2 changes: 1 addition & 1 deletion app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HTTP } from 'meteor/http';
import { API } from '../../../api/server';
import { getUploadFormData } from '../../../api/server/lib/getUploadFormData';
import { getWorkspaceAccessToken, getUserCloudAccessToken } from '../../../cloud/server';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Info } from '../../../utils';
import { Settings, Users } from '../../../models/server';
import { Apps } from '../orchestrator';
Expand Down
4 changes: 2 additions & 2 deletions app/apps/server/communication/uikit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ apiServer.disable('x-powered-by');
let corsEnabled = false;
let allowListOrigins = [];

settings.get('API_Enable_CORS', (_, value) => { corsEnabled = value; });
settings.watch('API_Enable_CORS', (value) => { corsEnabled = value; });

settings.get('API_CORS_Origin', (_, value) => {
settings.watch('API_CORS_Origin', (value) => {
allowListOrigins = value ? value.trim().split(',').map((origin) => String(origin).trim().toLocaleLowerCase()) : [];
});

Expand Down
23 changes: 14 additions & 9 deletions app/apps/server/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { AppInterface } from '@rocket.chat/apps-engine/definition/metadata';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
import { Meteor } from 'meteor/meteor';

import { Logger } from '../../logger';
import { AppsLogsModel, AppsModel, AppsPersistenceModel, Permissions } from '../../models';
import { settings } from '../../settings';
import { Logger } from '../../../server/lib/logger/Logger';
import { AppsLogsModel, AppsModel, AppsPersistenceModel } from '../../models/server';
import { settings, settingsRegistry } from '../../settings/server';
import { RealAppBridges } from './bridges';
import { AppMethods, AppServerNotifier, AppsRestApi, AppUIKitInteractionApi } from './communication';
import { AppMessagesConverter, AppRoomsConverter, AppSettingsConverter, AppUsersConverter } from './converters';
Expand All @@ -32,7 +32,6 @@ export class AppServerOrchestrator {
}

this._rocketchatLogger = new Logger('Rocket.Chat Apps');
Permissions.create('manage-apps', ['admin']);

if (typeof process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL === 'string' && process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL !== '') {
this._marketplaceUrl = process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL;
Expand Down Expand Up @@ -78,6 +77,9 @@ export class AppServerOrchestrator {
return this._model;
}

/**
* @returns {AppsPersistenceModel}
*/
getPersistenceModel() {
return this._persistModel;
}
Expand Down Expand Up @@ -130,6 +132,9 @@ export class AppServerOrchestrator {
return settings.get('Apps_Framework_Development_Mode') && !isTesting();
}

/**
* @returns {Logger}
*/
getRocketChatLogger() {
return this._rocketchatLogger;
}
Expand Down Expand Up @@ -195,7 +200,7 @@ export class AppServerOrchestrator {
export const AppEvents = AppInterface;
export const Apps = new AppServerOrchestrator();

settings.addGroup('General', function() {
settingsRegistry.addGroup('General', function() {
this.section('Apps', function() {
this.add('Apps_Logs_TTL', '30_days', {
type: 'select',
Expand Down Expand Up @@ -259,23 +264,23 @@ settings.addGroup('General', function() {
});
});

settings.get('Apps_Framework_Source_Package_Storage_Type', (_, value) => {
settings.watch('Apps_Framework_Source_Package_Storage_Type', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageType = value;
} else {
Apps.getAppSourceStorage().setStorage(value);
}
});

settings.get('Apps_Framework_Source_Package_Storage_FileSystem_Path', (_, value) => {
settings.watch('Apps_Framework_Source_Package_Storage_FileSystem_Path', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageFilesystemPath = value;
} else {
Apps.getAppSourceStorage().setFileSystemStoragePath(value);
}
});

settings.get('Apps_Framework_enabled', (key, isEnabled) => {
settings.watch('Apps_Framework_enabled', (isEnabled) => {
// In case this gets called before `Meteor.startup`
if (!Apps.isInitialized()) {
return;
Expand All @@ -288,7 +293,7 @@ settings.get('Apps_Framework_enabled', (key, isEnabled) => {
}
});

settings.get('Apps_Logs_TTL', (key, value) => {
settings.watch('Apps_Logs_TTL', (value) => {
if (!Apps.isInitialized()) {
return;
}
Expand Down
Loading