mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-16 21:01:20 +00:00
Merge pull request #55 from overleaf/bg-allow-fractional-drain-rate
allow fractional drain rate
This commit is contained in:
commit
d4f003fe0f
2 changed files with 9 additions and 2 deletions
|
@ -6,9 +6,16 @@ module.exports =
|
|||
clearInterval @interval
|
||||
if rate == 0
|
||||
return
|
||||
else if rate < 1
|
||||
# allow lower drain rates
|
||||
# e.g. rate=0.1 will drain one client every 10 seconds
|
||||
pollingInterval = 1000 / rate
|
||||
rate = 1
|
||||
else
|
||||
pollingInterval = 1000
|
||||
@interval = setInterval () =>
|
||||
@reconnectNClients(io, rate)
|
||||
, 1000
|
||||
, pollingInterval
|
||||
|
||||
RECONNECTED_CLIENTS: {}
|
||||
reconnectNClients: (io, N) ->
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = HttpApiController =
|
|||
startDrain: (req, res, next) ->
|
||||
io = req.app.get("io")
|
||||
rate = req.query.rate or "4"
|
||||
rate = parseInt(rate, 10)
|
||||
rate = parseFloat(rate) || 0
|
||||
logger.log {rate}, "setting client drain rate"
|
||||
DrainManager.startDrain io, rate
|
||||
res.send 204
|
Loading…
Reference in a new issue