Skip to content

Commit 8acf060

Browse files
committed
configurable healthcheck, also reduced default to 60s
1 parent 19ffd93 commit 8acf060

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

config/Config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default {
2424
resetCupScoreOnSkipAndRestart: true,
2525
/** Timeout after clicking manialink in milliseconds */
2626
manialinkInteractionTimeout: 50,
27+
/** Interval between pings to the server to check its online status in milliseconds */
28+
healthcheckInterval: 60000,
2729
/** Privilege levels for each of the administrative actions */
2830
privileges: {
2931
ban: 2,

src/Main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { VoteService } from './services/VoteService.js'
1414
import { RoundsService } from './services/RoundsService.js'
1515
import { fixRankCoherence } from './FixRankCoherence.js'
1616
import 'dotenv/config'
17+
import config from '../config/Config.js'
1718
import './Trakman.js'
1819

1920
await Logger.initialize()
@@ -75,17 +76,17 @@ await Events.initialize()
7576
Logger.trace('Controller events enabled')
7677
Logger.info('Controller started successfully')
7778

78-
process.on('SIGINT', async () => {
79+
process.on('SIGINT', () => {
7980
Logger.warn('Controller terminated, exiting...')
8081
process.exit(0)
8182
})
8283

8384
setInterval(async () => {
8485
Logger.debug('Checking if the dedicated server is alive...')
85-
const status: { Code: number, Name: string } | Error = await Client.call('GetStatus')
86+
const status = await Client.call('GetStatus')
8687
if (status instanceof Error) {
8788
// We don't need to wait to restart here since the timeout is 10s anyway - plenty of time for serv to start
88-
await Logger.fatal('Healthcheck failed - no connection to the server. Game state was: ', GameService.state)
89+
await Logger.fatal(`Healthcheck failed - no connection to the server. Game state was: ${GameService.state}`)
8990
}
9091
Logger.debug('Connection to the dedicated server exists.')
91-
}, 10000) // make this configurable?
92+
}, config.healthcheckInterval)

0 commit comments

Comments
 (0)