mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-11 09:00:23 -07:00
Server will create a thread dump on a heartbeat death
This commit is contained in:
parent
f8950359a2
commit
2a1e082485
1 changed files with 20 additions and 0 deletions
|
|
@ -16,10 +16,14 @@ import rs09.game.system.config.ServerConfigParser
|
||||||
import rs09.game.world.GameWorld
|
import rs09.game.world.GameWorld
|
||||||
import rs09.game.world.repository.Repository
|
import rs09.game.world.repository.Repository
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileWriter
|
||||||
|
import java.lang.management.ManagementFactory
|
||||||
|
import java.lang.management.ThreadMXBean
|
||||||
import java.net.BindException
|
import java.net.BindException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main class, for those that are unable to read the class' name.
|
* The main class, for those that are unable to read the class' name.
|
||||||
* @author Emperor
|
* @author Emperor
|
||||||
|
|
@ -108,6 +112,13 @@ object Server {
|
||||||
while(running){
|
while(running){
|
||||||
if(System.currentTimeMillis() - lastHeartbeat > 1800 && running){
|
if(System.currentTimeMillis() - lastHeartbeat > 1800 && running){
|
||||||
SystemLogger.logErr("Triggering reboot due to heartbeat timeout")
|
SystemLogger.logErr("Triggering reboot due to heartbeat timeout")
|
||||||
|
SystemLogger.logErr("Creating thread dump...")
|
||||||
|
val dump = threadDump(true, true)
|
||||||
|
FileWriter("latestdump.txt").use {
|
||||||
|
it.write(dump)
|
||||||
|
it.flush()
|
||||||
|
it.close()
|
||||||
|
}
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
delay(625)
|
delay(625)
|
||||||
|
|
@ -140,6 +151,15 @@ object Server {
|
||||||
return startTime
|
return startTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun threadDump(lockedMonitors: Boolean, lockedSynchronizers: Boolean): String? {
|
||||||
|
val threadDump = StringBuffer(System.lineSeparator())
|
||||||
|
val threadMXBean: ThreadMXBean = ManagementFactory.getThreadMXBean()
|
||||||
|
for (threadInfo in threadMXBean.dumpAllThreads(lockedMonitors, lockedSynchronizers)) {
|
||||||
|
threadDump.append(threadInfo.toString())
|
||||||
|
}
|
||||||
|
return threadDump.toString()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bastartTime.ZZ
|
* Sets the bastartTime.ZZ
|
||||||
* @param startTime the startTime to set.
|
* @param startTime the startTime to set.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue