mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Remove built-in pcntl support
This is a bolt-on feature that can't be disabled and causes serious grief for Unix server users, because it prevents ctrl+c aborting the server the normal way. Instead, we prefer introducing a plugin to implement this functionality, so that users can opt-in or opt-out.
This commit is contained in:
parent
390501ec35
commit
8bc33a849a
@ -121,7 +121,6 @@ use function file_exists;
|
|||||||
use function file_get_contents;
|
use function file_get_contents;
|
||||||
use function file_put_contents;
|
use function file_put_contents;
|
||||||
use function filemtime;
|
use function filemtime;
|
||||||
use function function_exists;
|
|
||||||
use function gc_collect_cycles;
|
use function gc_collect_cycles;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function getmypid;
|
use function getmypid;
|
||||||
@ -137,8 +136,6 @@ use function max;
|
|||||||
use function microtime;
|
use function microtime;
|
||||||
use function min;
|
use function min;
|
||||||
use function mkdir;
|
use function mkdir;
|
||||||
use function pcntl_signal;
|
|
||||||
use function pcntl_signal_dispatch;
|
|
||||||
use function preg_replace;
|
use function preg_replace;
|
||||||
use function random_bytes;
|
use function random_bytes;
|
||||||
use function realpath;
|
use function realpath;
|
||||||
@ -162,9 +159,6 @@ use const DIRECTORY_SEPARATOR;
|
|||||||
use const PHP_EOL;
|
use const PHP_EOL;
|
||||||
use const PHP_INT_MAX;
|
use const PHP_INT_MAX;
|
||||||
use const PTHREADS_INHERIT_NONE;
|
use const PTHREADS_INHERIT_NONE;
|
||||||
use const SIGHUP;
|
|
||||||
use const SIGINT;
|
|
||||||
use const SIGTERM;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class that manages everything
|
* The class that manages everything
|
||||||
@ -232,9 +226,6 @@ class Server{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $sendUsageTicker = 0;
|
private $sendUsageTicker = 0;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $dispatchSignals = false;
|
|
||||||
|
|
||||||
/** @var \AttachableThreadedLogger */
|
/** @var \AttachableThreadedLogger */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
@ -1850,13 +1841,6 @@ class Server{
|
|||||||
|
|
||||||
$this->tickCounter = 0;
|
$this->tickCounter = 0;
|
||||||
|
|
||||||
if(function_exists("pcntl_signal")){
|
|
||||||
pcntl_signal(SIGTERM, [$this, "handleSignal"]);
|
|
||||||
pcntl_signal(SIGINT, [$this, "handleSignal"]);
|
|
||||||
pcntl_signal(SIGHUP, [$this, "handleSignal"]);
|
|
||||||
$this->dispatchSignals = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [GameMode::toTranslation($this->getGamemode())]));
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [GameMode::toTranslation($this->getGamemode())]));
|
||||||
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.startFinished", [round(microtime(true) - \pocketmine\START_TIME, 3)]));
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.startFinished", [round(microtime(true) - \pocketmine\START_TIME, 3)]));
|
||||||
@ -1865,12 +1849,6 @@ class Server{
|
|||||||
$this->forceShutdown();
|
$this->forceShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleSignal($signo){
|
|
||||||
if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){
|
|
||||||
$this->shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Throwable $e
|
* @param \Throwable $e
|
||||||
* @param array|null $trace
|
* @param array|null $trace
|
||||||
@ -2222,10 +2200,6 @@ class Server{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->dispatchSignals and $this->tickCounter % 5 === 0){
|
|
||||||
pcntl_signal_dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getMemoryManager()->check();
|
$this->getMemoryManager()->check();
|
||||||
|
|
||||||
Timings::$serverTickTimer->stopTiming();
|
Timings::$serverTickTimer->stopTiming();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user