mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4890 from overleaf/jpa-clsi-maint
[clsi] put server into maintenance mode when reaching zero capacity GitOrigin-RevId: d1af260a3bfba7852519b3bc369a6747e79f3b18
This commit is contained in:
parent
18192e4559
commit
1dc9f428fa
1 changed files with 11 additions and 3 deletions
|
@ -330,11 +330,19 @@ const loadTcpServer = net.createServer(function (socket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const freeLoad = availableWorkingCpus - currentLoad
|
const freeLoad = availableWorkingCpus - currentLoad
|
||||||
let freeLoadPercentage = Math.round((freeLoad / availableWorkingCpus) * 100)
|
const freeLoadPercentage = Math.round(
|
||||||
|
(freeLoad / availableWorkingCpus) * 100
|
||||||
|
)
|
||||||
if (freeLoadPercentage <= 0) {
|
if (freeLoadPercentage <= 0) {
|
||||||
freeLoadPercentage = 0 // when its 0 the server is set to drain and will move projects to different servers
|
// When its 0 the server is set to drain implicitly.
|
||||||
|
// Drain will move new projects to different servers.
|
||||||
|
// Drain will keep existing projects assigned to the same server.
|
||||||
|
// Maint will more existing and new projects to different servers.
|
||||||
|
socket.write(`maint, 0%\n`, 'ASCII')
|
||||||
|
} else {
|
||||||
|
// Ready will cancel the maint state.
|
||||||
|
socket.write(`up, ready, ${freeLoadPercentage}%\n`, 'ASCII')
|
||||||
}
|
}
|
||||||
socket.write(`up, ${freeLoadPercentage}%\n`, 'ASCII')
|
|
||||||
return socket.end()
|
return socket.end()
|
||||||
} else {
|
} else {
|
||||||
socket.write(`${STATE}\n`, 'ASCII')
|
socket.write(`${STATE}\n`, 'ASCII')
|
||||||
|
|
Loading…
Reference in a new issue