minecraft-server-hibernation
minecraft-server-hibernation copied to clipboard
java server process keeps running when msh exits because of a panic
(... the running instance of the minceraft server, prevents msh from launching an other instance of the server)
case:
- minecraft server running as child process of msh
- msh panic and msh exit
result:
- java server process is detached and not killed
cause:
- unknown
this function does not have anything to do with the problem: setting
SysProcAttr
or not, the problem persist https://github.com/gekigek99/minecraft-server-hibernation/blob/5047d8d8b85ca161c8013bb181294d19b7410c03/lib/osctrl/osctrl_windows.go#L9-L16
solution:
- in msh, when the minecraft server is launched, add a
defer servctrl.ServTerminal.cmd.Process.Kill()
statement to kill the process group when msh exits (?) is thedefer
executed even if a panic happens?
Especially check function servctrl.killMSifOnlineAfterTimeout()
since it kills only the java parent process and not the java server process.
A useful function to implement might be osctrl.KillProcessTree
.
recover()
function in main()
could check if the server is running and in that case kill the process before the panic exit
recover() function in main() could check if the server is running and in that case kill the process before the panic exit
not possible as recover()
works only for panics in the subroutine
added fix for linux in 9897f0c92e0dedaaf4fccca5e071509115dfb805 (NOT TESTED)
A complete solution would be using cgroups (linux) and/or job objects (windows) (gist)
Considering that there is msh pterodactyl-egg which solves completely the issue by rebooting the whole container in case of msh panic:
For now this issue is halted
might even be closed in the future as it's a very complex solution for a problem (random panics) that should not exist.
corrected 9897f0c92e0dedaaf4fccca5e071509115dfb805 in f186b330f5dc2edaee4fd69a0b4cb041f47f6e08 as Pdeathsig
is not supported on darwin OS
Closing as halted