diff --git a/services/web/app.js b/services/web/app.js index 927e5f9060..b2d4e59908 100644 --- a/services/web/app.js +++ b/services/web/app.js @@ -23,6 +23,11 @@ if ((Settings.sentry != null ? Settings.sentry.dsn : undefined) != null) { logger.initializeErrorReporting(Settings.sentry.dsn) } +const http = require('http') +const https = require('https') +http.globalAgent.maxSockets = Settings.limits.httpGlobalAgentMaxSockets +https.globalAgent.maxSockets = Settings.limits.httpsGlobalAgentMaxSockets + metrics.memory.monitor(logger) const Server = require('./app/src/infrastructure/Server') diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index a6952a7d68..b51cd07f5a 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -1,8 +1,6 @@ const { merge } = require('@overleaf/settings/merge') let defaultFeatures, siteUrl -const http = require('http') -http.globalAgent.maxSockets = 300 // Make time interval config easier. const seconds = 1000 @@ -74,6 +72,11 @@ const parseTextExtensions = function (extensions) { } module.exports = { + limits: { + httpGlobalAgentMaxSockets: 300, + httpsGlobalAgentMaxSockets: 300, + }, + allowAnonymousReadAndWriteSharing: process.env.SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',