mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 02:13:35 -05:00
26f3f3e2e2
Migrate scripts folder to esm 1/x GitOrigin-RevId: 4a4bc9a161f144fdb40ce3f2a0a9313b36c6df81
31 lines
998 B
JavaScript
31 lines
998 B
JavaScript
/**
|
|
* Ensures that the specific MongoDB connection timeout is set.
|
|
*
|
|
* @param {number} timeoutInMS
|
|
* @returns {void}
|
|
*/
|
|
export function ensureMongoTimeout(timeoutInMS) {
|
|
if (process.env.MONGO_SOCKET_TIMEOUT !== timeoutInMS.toString()) {
|
|
throw new Error(
|
|
`must run with higher mongo timeout: MONGO_SOCKET_TIMEOUT=${timeoutInMS} node ${process.argv[1]}`
|
|
)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ensures MongoDB queries are running on secondary and the specific connection timeout is set.
|
|
*
|
|
* @param {number} timeoutInMS
|
|
* @returns {void}
|
|
*/
|
|
export function ensureRunningOnMongoSecondaryWithTimeout(timeoutInMS) {
|
|
if (
|
|
process.env.MONGO_SOCKET_TIMEOUT !== timeoutInMS.toString() ||
|
|
process.env.MONGO_CONNECTION_STRING !==
|
|
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
|
) {
|
|
throw new Error(
|
|
`must run on secondary with higher mongo timeout: MONGO_SOCKET_TIMEOUT=${timeoutInMS} MONGO_CONNECTION_STRING="$READ_ONLY_MONGO_CONNECTION_STRING" node ${process.argv[1]}`
|
|
)
|
|
}
|
|
}
|