mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 13:35:29 +00:00
Ctrl+C handling and kill signals are working again
This commit is contained in:
parent
cb645fa288
commit
92cabced97
@ -1822,9 +1822,10 @@ class Server{
|
||||
$this->tickCounter = 0;
|
||||
|
||||
if(function_exists("pcntl_signal")){
|
||||
pcntl_signal(SIGTERM, array($this, "shutdown"));
|
||||
pcntl_signal(SIGINT, array($this, "shutdown"));
|
||||
pcntl_signal(SIGHUP, array($this, "shutdown"));
|
||||
pcntl_signal(SIGTERM, [$this, "handleSignal"]);
|
||||
pcntl_signal(SIGINT, [$this, "handleSignal"]);
|
||||
pcntl_signal(SIGHUP, [$this, "handleSignal"]);
|
||||
$this->getScheduler()->scheduleRepeatingTask(new CallbackTask("pcntl_signal_dispatch"), 5);
|
||||
}
|
||||
|
||||
$this->logger->info("Default game type: " . self::getGamemodeString($this->getGamemode())); //TODO: string name
|
||||
@ -1837,6 +1838,12 @@ class Server{
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
public function handleSignal($signo){
|
||||
if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){
|
||||
$this->shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkTicks(){
|
||||
if($this->getTicksPerSecond() < 12){
|
||||
$this->logger->warning("Can't keep up! Is the server overloaded?");
|
||||
|
Loading…
x
Reference in New Issue
Block a user