mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Stop the server on Ctrl+C and SIGINT signal
This commit is contained in:
parent
a8d90955c7
commit
c61a3dcd12
@ -700,6 +700,9 @@ public final class MinecraftServer {
|
|||||||
if (terminalEnabled) {
|
if (terminalEnabled) {
|
||||||
MinestomTerminal.start();
|
MinestomTerminal.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop the server on SIGINT
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,9 @@ public class MinestomTerminal {
|
|||||||
command = reader.readLine(PROMPT);
|
command = reader.readLine(PROMPT);
|
||||||
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
||||||
} catch (UserInterruptException e) {
|
} catch (UserInterruptException e) {
|
||||||
// Ignore
|
// Handle Ctrl + C
|
||||||
|
System.exit(0);
|
||||||
|
return;
|
||||||
} catch (EndOfFileException e) {
|
} catch (EndOfFileException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user