return 0 for server which is being hammered

socket.destroy when finished
This commit is contained in:
Henry Oswald 2016-04-08 15:39:02 +01:00
parent 02c7a96161
commit 29e3668b52

View file

@ -135,10 +135,12 @@ server = net.createServer (socket) ->
availableWorkingCpus = os.cpus().length - 1
freeLoad = availableWorkingCpus - fiveMinLoad
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.on "error", (err)->
console.log err, "error with socket"
socket.pipe socket
socket.destroy()
return
port = 4080