print mem usage
This commit is contained in:
parent
5d76edafaf
commit
6b1c3fb085
2 changed files with 11 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ function persistChangedGames() {
|
||||||
puzzle: game.puzzle,
|
puzzle: game.puzzle,
|
||||||
players: game.players,
|
players: game.players,
|
||||||
}))
|
}))
|
||||||
|
console.info(`[INFO] persisted game ${game.id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,10 +178,20 @@ const server = app.listen(
|
||||||
)
|
)
|
||||||
wss.listen()
|
wss.listen()
|
||||||
|
|
||||||
|
|
||||||
|
const memoryUsageHuman = () => {
|
||||||
|
const used = process.memoryUsage().heapUsed / 1024 / 1024
|
||||||
|
return `${Math.round(used * 100) / 100}M`
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Mem: ${memoryUsageHuman()}`)
|
||||||
|
|
||||||
// persist games in fixed interval
|
// persist games in fixed interval
|
||||||
const persistInterval = setInterval(() => {
|
const persistInterval = setInterval(() => {
|
||||||
console.log('Persisting games...');
|
console.log('Persisting games...');
|
||||||
Game.persistChangedGames()
|
Game.persistChangedGames()
|
||||||
|
|
||||||
|
console.log(`Mem: ${memoryUsageHuman()}`)
|
||||||
}, config.persistence.interval)
|
}, config.persistence.interval)
|
||||||
|
|
||||||
const gracefulShutdown = (signal) => {
|
const gracefulShutdown = (signal) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue