From ab5c965f20c868de79e382466bd8dadbaa81ecc5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 16 Jan 2024 21:53:54 +0100 Subject: [PATCH] Use SIGUSR1 to softstop --- src/de/steamwar/bungeecore/Subserver.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index 2cdfcbc..9abee32 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -136,10 +136,15 @@ public class Subserver { } public void stop() { - if(checkpoint) - process.children().forEach(ProcessHandle::destroy); - else - execute("stop"); + try { + long pid = process.pid(); + if(checkpoint) + pid = process.children().findAny().map(ProcessHandle::pid).orElse(pid); + + Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(pid)}); + } catch (IOException e) { + ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Failed to send SIGUSR1 to subserver.", e); + } try { if(!process.waitFor(1, TimeUnit.MINUTES))