mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add script to increase paid compile timeouts to 240s
This commit is contained in:
parent
89efa7e83e
commit
05aedf1e09
1 changed files with 64 additions and 0 deletions
64
services/web/scripts/increase_compile_timeouts.js
Normal file
64
services/web/scripts/increase_compile_timeouts.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
const mongojs = require('../app/js/infrastructure/mongojs')
|
||||
const { db } = mongojs
|
||||
const async = require('async')
|
||||
const minilist = require('minimist')
|
||||
|
||||
const newTimeout = 240
|
||||
const oldTimeoutLimits = {$gt: 60, $lt: 240}
|
||||
|
||||
const updateUser = function (user, callback) {
|
||||
console.log(`Updating user ${user._id}`)
|
||||
const update = {
|
||||
$set: {
|
||||
'features.compileTimeout': newTimeout
|
||||
}
|
||||
}
|
||||
db.users.update({
|
||||
_id: user._id,
|
||||
'features.compileTimeout': oldTimeoutLimits
|
||||
}, update, callback)
|
||||
}
|
||||
|
||||
const updateUsers = (users, callback) =>
|
||||
async.eachLimit(users, ASYNC_LIMIT, updateUser, function (error) {
|
||||
if (error) {
|
||||
callback(error)
|
||||
return
|
||||
}
|
||||
counter += users.length
|
||||
console.log(`${counter} users updated`)
|
||||
loopForUsers(callback)
|
||||
})
|
||||
|
||||
var loopForUsers = callback =>
|
||||
db.users.find(
|
||||
{ 'features.compileTimeout': oldTimeoutLimits },
|
||||
{ 'features.compileTimeout': 1 }
|
||||
).limit(FETCH_LIMIT, function (error, users) {
|
||||
if (error) {
|
||||
callback(error)
|
||||
return
|
||||
}
|
||||
if (users.length === 0) {
|
||||
console.log(`DONE (${counter} users updated)`)
|
||||
return callback()
|
||||
}
|
||||
updateUsers(users, callback)
|
||||
})
|
||||
|
||||
var counter = 0
|
||||
var run = () =>
|
||||
loopForUsers(function (error) {
|
||||
if (error) { throw error }
|
||||
process.exit()
|
||||
})
|
||||
|
||||
let FETCH_LIMIT, ASYNC_LIMIT
|
||||
var setup = function () {
|
||||
let args = minilist(process.argv.slice(2))
|
||||
FETCH_LIMIT = (args.fetch) ? args.fetch : 100
|
||||
ASYNC_LIMIT = (args.async) ? args.async : 10
|
||||
}
|
||||
|
||||
setup()
|
||||
run()
|
Loading…
Reference in a new issue