Attempt to fix server hanging on shutdown

This commit is contained in:
ceikry
2021-07-22 22:18:33 -05:00
parent 65b4113ffb
commit d4d4727cf3
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -40,6 +40,7 @@ object Server {
/**
* The NIO reactor.
*/
@JvmStatic
var reactor: NioReactor? = null
/**
@@ -72,7 +73,8 @@ object Server {
Runtime.getRuntime().addShutdownHook(ServerConstants.SHUTDOWN_HOOK)
SystemLogger.logInfo("Starting networking...")
try {
NioReactor.configure(43594 + GameWorld.settings?.worldId!!).start()
reactor = NioReactor.configure(43594 + GameWorld.settings?.worldId!!)
reactor!!.start()
} catch (e: BindException) {
SystemLogger.logErr("Port " + (43594 + GameWorld.settings?.worldId!!) + " is already in use!")
throw e