minecraft-server-hibernation icon indicating copy to clipboard operation
minecraft-server-hibernation copied to clipboard

java server process keeps running when msh exits because of a panic

Open gekigek99 opened this issue 3 years ago • 2 comments

(... 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 the defer executed even if a panic happens?

gekigek99 avatar Jun 13 '21 14:06 gekigek99

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.

gekigek99 avatar Aug 01 '21 00:08 gekigek99

recover() function in main() could check if the server is running and in that case kill the process before the panic exit

gekigek99 avatar Feb 10 '22 11:02 gekigek99

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

gekigek99 avatar Nov 16 '22 19:11 gekigek99

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.

gekigek99 avatar Nov 16 '22 20:11 gekigek99

corrected 9897f0c92e0dedaaf4fccca5e071509115dfb805 in f186b330f5dc2edaee4fd69a0b4cb041f47f6e08 as Pdeathsig is not supported on darwin OS

gekigek99 avatar Nov 26 '22 16:11 gekigek99

Closing as halted

gekigek99 avatar Apr 14 '23 15:04 gekigek99