mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
Possible fix for crashing server not stopping
This commit is contained in:
parent
8601405a88
commit
66acb5cdd7
@ -132,6 +132,8 @@ class Server{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $isRunning = true;
|
private $isRunning = true;
|
||||||
|
|
||||||
|
private $hasStopped = false;
|
||||||
|
|
||||||
/** @var PluginManager */
|
/** @var PluginManager */
|
||||||
private $pluginManager = null;
|
private $pluginManager = null;
|
||||||
|
|
||||||
@ -1852,39 +1854,52 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function forceShutdown(){
|
public function forceShutdown(){
|
||||||
$this->shutdown();
|
if($this->hasStopped){
|
||||||
if($this->rcon instanceof RCON){
|
return;
|
||||||
$this->rcon->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->getProperty("settings.upnp-forwarding", false) === true){
|
try{
|
||||||
$this->logger->info("[UPnP] Removing port forward...");
|
$this->hasStopped = true;
|
||||||
UPnP::RemovePortForward($this->getPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->pluginManager->disablePlugins();
|
$this->shutdown();
|
||||||
|
if($this->rcon instanceof RCON){
|
||||||
|
$this->rcon->stop();
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->players as $player){
|
if($this->getProperty("settings.upnp-forwarding", false) === true){
|
||||||
$player->close(TextFormat::YELLOW . $player->getName() . " has left the game", $this->getProperty("settings.shutdown-message", "Server closed"));
|
$this->logger->info("[UPnP] Removing port forward...");
|
||||||
}
|
UPnP::RemovePortForward($this->getPort());
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->getLevels() as $level){
|
$this->pluginManager->disablePlugins();
|
||||||
$this->unloadLevel($level, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->generationManager instanceof GenerationRequestManager){
|
foreach($this->players as $player){
|
||||||
$this->generationManager->shutdown();
|
$player->close(TextFormat::YELLOW . $player->getName() . " has left the game", $this->getProperty("settings.shutdown-message", "Server closed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
HandlerList::unregisterAll();
|
foreach($this->getLevels() as $level){
|
||||||
$this->scheduler->cancelAllTasks();
|
$this->unloadLevel($level, true);
|
||||||
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
|
}
|
||||||
|
|
||||||
$this->properties->save();
|
if($this->generationManager instanceof GenerationRequestManager){
|
||||||
|
$this->generationManager->shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
$this->console->kill();
|
HandlerList::unregisterAll();
|
||||||
foreach($this->interfaces as $interface){
|
|
||||||
$interface->shutdown();
|
$this->scheduler->cancelAllTasks();
|
||||||
|
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
|
||||||
|
|
||||||
|
$this->properties->save();
|
||||||
|
|
||||||
|
$this->console->kill();
|
||||||
|
|
||||||
|
foreach($this->interfaces as $interface){
|
||||||
|
$interface->shutdown();
|
||||||
|
}
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$this->logger->emergency("Crashed while crashing, killing process");
|
||||||
|
@kill(getmypid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class ServerScheduler{
|
|||||||
}
|
}
|
||||||
$this->tasks = [];
|
$this->tasks = [];
|
||||||
$this->asyncTaskStorage = [];
|
$this->asyncTaskStorage = [];
|
||||||
$this->asyncPool->shutdown();
|
//$this->asyncPool->shutdown();
|
||||||
$this->asyncTasks = 0;
|
$this->asyncTasks = 0;
|
||||||
$this->queue = new ReversePriorityQueue();
|
$this->queue = new ReversePriorityQueue();
|
||||||
$this->asyncPool = new \Pool(self::$WORKERS, AsyncWorker::class);
|
$this->asyncPool = new \Pool(self::$WORKERS, AsyncWorker::class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user