Add startup log messages

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent fbb9694feb
commit dc4b769f29
  1. 10
      game/src/main/kotlin/org/openrs2/game/GameCommand.kt
  2. 12
      game/src/main/kotlin/org/openrs2/game/GameServer.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<String>): 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()
}
}

@ -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
}
}

Loading…
Cancel
Save