split Game and GameStorage

This commit is contained in:
Zutatensuppe 2021-04-30 21:00:30 +02:00
parent e83d3e8d61
commit 792f0d4c31
5 changed files with 108 additions and 93 deletions

View file

@ -21,6 +21,7 @@ import {
TEMPLATE_DIR,
} from './Dirs.js'
import GameCommon from '../common/GameCommon.js'
import GameStorage from './GameStorage.js'
const log = logger('index.js')
@ -222,7 +223,7 @@ wss.on('message', async ({socket, data}) => {
}
})
Game.loadAllGames()
GameStorage.loadGames()
const server = app.listen(
port,
hostname,
@ -245,7 +246,7 @@ memoryUsageHuman()
// persist games in fixed interval
const persistInterval = setInterval(() => {
log.log('Persisting games...')
Game.persistChangedGames()
GameStorage.persistGames()
memoryUsageHuman()
}, config.persistence.interval)
@ -257,7 +258,7 @@ const gracefulShutdown = (signal) => {
clearInterval(persistInterval)
log.log('persisting games...')
Game.persistChangedGames()
GameStorage.persistGames()
log.log('shutting down webserver...')
server.close()