From dc4b769f2912f657a9990c942715a69a95da1d35 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 16 May 2021 19:58:16 +0100 Subject: [PATCH] Add startup log messages Signed-off-by: Graham --- game/src/main/kotlin/org/openrs2/game/GameCommand.kt | 10 +++++++++- game/src/main/kotlin/org/openrs2/game/GameServer.kt | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/game/src/main/kotlin/org/openrs2/game/GameCommand.kt b/game/src/main/kotlin/org/openrs2/game/GameCommand.kt index 1b273825..35a68676 100644 --- a/game/src/main/kotlin/org/openrs2/game/GameCommand.kt +++ b/game/src/main/kotlin/org/openrs2/game/GameCommand.kt @@ -1,6 +1,7 @@ package org.openrs2.game import com.github.ajalt.clikt.core.CliktCommand +import com.github.michaelbull.logging.InlineLogger import com.google.inject.Guice import org.openrs2.inject.CloseableInjector @@ -8,9 +9,16 @@ public fun main(args: Array): Unit = GameCommand().main(args) public class GameCommand : CliktCommand(name = "game") { override fun run() { + val start = System.nanoTime() + logger.info { "Starting OpenRS2..." } + CloseableInjector(Guice.createInjector(GameModule)).use { injector -> val server = injector.getInstance(GameServer::class.java) - server.run() + server.run(start) } } + + private companion object { + private val logger = InlineLogger() + } } diff --git a/game/src/main/kotlin/org/openrs2/game/GameServer.kt b/game/src/main/kotlin/org/openrs2/game/GameServer.kt index d733b121..93359c5c 100644 --- a/game/src/main/kotlin/org/openrs2/game/GameServer.kt +++ b/game/src/main/kotlin/org/openrs2/game/GameServer.kt @@ -1,5 +1,6 @@ package org.openrs2.game +import com.github.michaelbull.logging.InlineLogger import com.google.common.util.concurrent.Service import com.google.common.util.concurrent.ServiceManager import javax.inject.Inject @@ -11,8 +12,17 @@ public class GameServer @Inject constructor( ) { private val serviceManager = ServiceManager(services) - public fun run() { + public fun run(start: Long) { serviceManager.startAsync().awaitHealthy() + + val elapsed = System.nanoTime() - start + logger.info { "Started OpenRS2 in ${elapsed / NANOS_PER_MILLI} milliseconds" } + serviceManager.awaitStopped() } + + private companion object { + private val logger = InlineLogger() + private const val NANOS_PER_MILLI = 1_000_000 + } }