Skip to content

Commit

Permalink
Merge branch 'dev' into patch/update-koe
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 authored Sep 20, 2024
2 parents 18cf2ef + 634541e commit 0747d34
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions LavalinkServer/src/main/java/lavalink/server/io/ShutdownHandler.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package lavalink.server.io

import org.springframework.web.socket.CloseStatus

class ShutdownHandler(private val socketServer: SocketServer) : Thread("lavalink-shutdown-handler") {
init {
isDaemon = false // we want this thread to block shutdown until it has finished running
}

override fun run() {
socketServer.contexts.forEach {
// don't care about exceptions here, the JVM's shutting down anyway.
it.runCatching { closeWebSocket(CloseStatus.GOING_AWAY.code) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ final class SocketServer(
private val statsCollector = StatsCollector(this)
private val charPool = ('a'..'z') + ('0'..'9')

init {
Runtime.getRuntime().addShutdownHook(ShutdownHandler(this))
}

companion object {
private val log = LoggerFactory.getLogger(SocketServer::class.java)

Expand Down

0 comments on commit 0747d34

Please sign in to comment.