2024-11-08 05:21:56 -05:00
|
|
|
const http = require('node:http')
|
2020-02-16 09:03:45 -05:00
|
|
|
http.globalAgent.maxSockets = 300
|
2024-11-14 04:44:58 -05:00
|
|
|
http.globalAgent.keepAlive = false
|
2014-04-28 11:45:59 -04:00
|
|
|
|
2020-02-16 09:03:43 -05:00
|
|
|
const Settings = {
|
2020-02-16 09:03:45 -05:00
|
|
|
internal: {
|
|
|
|
docstore: {
|
|
|
|
port: 3016,
|
2024-04-25 08:56:00 -04:00
|
|
|
host: process.env.LISTEN_ADDRESS || '127.0.0.1',
|
2021-07-13 07:04:48 -04:00
|
|
|
},
|
2020-02-16 09:03:45 -05:00
|
|
|
},
|
2014-04-28 11:45:59 -04:00
|
|
|
|
2024-02-22 06:03:27 -05:00
|
|
|
mongo: {
|
|
|
|
options: {
|
|
|
|
monitorCommands: true,
|
|
|
|
},
|
|
|
|
},
|
2015-06-01 17:24:40 -04:00
|
|
|
|
2020-02-16 09:03:45 -05:00
|
|
|
docstore: {
|
2021-01-04 08:36:19 -05:00
|
|
|
archiveOnSoftDelete: process.env.ARCHIVE_ON_SOFT_DELETE === 'true',
|
2021-01-04 12:04:33 -05:00
|
|
|
keepSoftDeletedDocsArchived:
|
|
|
|
process.env.KEEP_SOFT_DELETED_DOCS_ARCHIVED === 'true',
|
2021-01-04 08:36:19 -05:00
|
|
|
|
2023-05-08 05:45:08 -04:00
|
|
|
backend: process.env.BACKEND,
|
2020-02-16 09:03:45 -05:00
|
|
|
healthCheck: {
|
2021-07-13 07:04:48 -04:00
|
|
|
project_id: process.env.HEALTH_CHECK_PROJECT_ID,
|
2020-07-23 14:42:20 -04:00
|
|
|
},
|
2020-08-10 06:55:39 -04:00
|
|
|
bucket: process.env.BUCKET_NAME || process.env.AWS_BUCKET || 'bucket',
|
2020-07-23 14:42:20 -04:00
|
|
|
gcs: {
|
|
|
|
unlockBeforeDelete: process.env.GCS_UNLOCK_BEFORE_DELETE === 'true',
|
|
|
|
deletedBucketSuffix: process.env.GCS_DELETED_BUCKET_SUFFIX,
|
2021-07-13 07:04:48 -04:00
|
|
|
deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50,
|
|
|
|
},
|
2020-02-16 09:03:45 -05:00
|
|
|
},
|
2015-11-06 07:42:44 -05:00
|
|
|
|
2021-02-18 05:10:14 -05:00
|
|
|
max_deleted_docs: parseInt(process.env.MAX_DELETED_DOCS, 10) || 2000,
|
|
|
|
|
2021-04-16 04:27:09 -04:00
|
|
|
max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024, // 2mb
|
|
|
|
|
2022-03-04 10:17:16 -05:00
|
|
|
maxJsonRequestSize:
|
|
|
|
parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
|
|
|
|
|
2021-06-08 07:59:13 -04:00
|
|
|
unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50,
|
2021-07-13 07:04:48 -04:00
|
|
|
parallelArchiveJobs: parseInt(process.env.PARALLEL_ARCHIVE_JOBS, 10) || 5,
|
2022-05-17 07:49:13 -04:00
|
|
|
archivingLockDurationMs:
|
|
|
|
parseInt(process.env.ARCHIVING_LOCK_DURATION_MS, 10) || 60000,
|
2020-02-16 09:03:45 -05:00
|
|
|
}
|
2016-11-28 11:51:43 -05:00
|
|
|
|
2021-05-19 15:22:02 -04:00
|
|
|
if (process.env.MONGO_CONNECTION_STRING) {
|
2020-02-16 09:03:45 -05:00
|
|
|
Settings.mongo.url = process.env.MONGO_CONNECTION_STRING
|
2021-05-19 15:22:02 -04:00
|
|
|
} else if (process.env.MONGO_HOST) {
|
2020-02-16 09:03:45 -05:00
|
|
|
Settings.mongo.url = `mongodb://${process.env.MONGO_HOST}/sharelatex`
|
2020-02-16 09:03:43 -05:00
|
|
|
} else {
|
2020-02-16 09:03:45 -05:00
|
|
|
Settings.mongo.url = 'mongodb://127.0.0.1/sharelatex'
|
2020-02-16 09:03:43 -05:00
|
|
|
}
|
2018-09-28 06:50:38 -04:00
|
|
|
|
2020-02-16 09:03:45 -05:00
|
|
|
if (
|
2021-05-19 15:22:02 -04:00
|
|
|
process.env.AWS_ACCESS_KEY_ID &&
|
|
|
|
process.env.AWS_SECRET_ACCESS_KEY &&
|
|
|
|
process.env.AWS_BUCKET
|
2020-02-16 09:03:45 -05:00
|
|
|
) {
|
|
|
|
Settings.docstore.s3 = {
|
|
|
|
key: process.env.AWS_ACCESS_KEY_ID,
|
|
|
|
secret: process.env.AWS_SECRET_ACCESS_KEY,
|
2020-07-23 14:42:20 -04:00
|
|
|
bucket: process.env.AWS_BUCKET,
|
|
|
|
endpoint: process.env.AWS_S3_ENDPOINT,
|
|
|
|
pathStyle: process.env.AWS_S3_PATH_STYLE,
|
2021-07-13 07:04:48 -04:00
|
|
|
partSize: parseInt(process.env.AWS_S3_PARTSIZE) || 100 * 1024 * 1024,
|
2020-07-23 14:42:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.GCS_API_ENDPOINT) {
|
|
|
|
Settings.docstore.gcs.endpoint = {
|
|
|
|
apiEndpoint: process.env.GCS_API_ENDPOINT,
|
2021-07-13 07:04:48 -04:00
|
|
|
projectId: process.env.GCS_PROJECT_ID,
|
2020-07-23 14:42:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.FALLBACK_BACKEND) {
|
|
|
|
Settings.docstore.fallback = {
|
|
|
|
backend: process.env.FALLBACK_BACKEND,
|
|
|
|
// mapping of bucket names on the fallback, to bucket names on the primary.
|
|
|
|
// e.g. { myS3UserFilesBucketName: 'myGoogleUserFilesBucketName' }
|
|
|
|
buckets: JSON.parse(process.env.FALLBACK_BUCKET_MAPPING || '{}'),
|
2021-07-13 07:04:48 -04:00
|
|
|
copyOnMiss: process.env.COPY_ON_MISS === 'true',
|
2020-02-16 09:03:45 -05:00
|
|
|
}
|
2020-02-16 09:03:43 -05:00
|
|
|
}
|
2018-09-28 06:50:38 -04:00
|
|
|
|
2020-02-16 09:03:45 -05:00
|
|
|
module.exports = Settings
|