Merge pull request #49 from sharelatex/ho-one-cpu-size

if host has 1 cpu (staging) then set availableWorkingCpus to 1
This commit is contained in:
Henry Oswald 2017-02-20 15:20:04 +00:00 committed by GitHub
commit 6aea5199c8

View file

@ -176,7 +176,13 @@ server = net.createServer (socket) ->
socket.destroy()
currentLoad = os.loadavg()[0]
# On staging there may be 1 cpu on host, don't want to set availableWorkingCpus to 0 in that instance
if os.cpus().length == 1
availableWorkingCpus = 1
else
availableWorkingCpus = os.cpus().length - 1
freeLoad = availableWorkingCpus - currentLoad
freeLoadPercentage = Math.round((freeLoad / availableWorkingCpus) * 100)
if freeLoadPercentage <= 0