mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
return 0 for server which is being hammered
socket.destroy when finished
This commit is contained in:
parent
02c7a96161
commit
29e3668b52
1 changed files with 3 additions and 1 deletions
|
@ -135,10 +135,12 @@ server = net.createServer (socket) ->
|
||||||
availableWorkingCpus = os.cpus().length - 1
|
availableWorkingCpus = os.cpus().length - 1
|
||||||
freeLoad = availableWorkingCpus - fiveMinLoad
|
freeLoad = availableWorkingCpus - fiveMinLoad
|
||||||
freeLoadPercentage = Math.round((freeLoad / availableWorkingCpus) * 100)
|
freeLoadPercentage = Math.round((freeLoad / availableWorkingCpus) * 100)
|
||||||
|
if freeLoadPercentage < 0
|
||||||
|
freeLoadPercentage = 1 # when its 0 the server is set to drain and will move projects about
|
||||||
socket.write "up, #{freeLoadPercentage}%\n", "ASCII"
|
socket.write "up, #{freeLoadPercentage}%\n", "ASCII"
|
||||||
socket.on "error", (err)->
|
socket.on "error", (err)->
|
||||||
console.log err, "error with socket"
|
console.log err, "error with socket"
|
||||||
socket.pipe socket
|
socket.destroy()
|
||||||
return
|
return
|
||||||
|
|
||||||
port = 4080
|
port = 4080
|
||||||
|
|
Loading…
Reference in a new issue