Possible fix for crashing server not stopping

This commit is contained in:
Shoghi Cervantes 2014-10-31 23:10:12 +01:00
parent 8601405a88
commit 66acb5cdd7
2 changed files with 40 additions and 25 deletions

View File

@ -132,6 +132,8 @@ class Server{
/** @var bool */
private $isRunning = true;
private $hasStopped = false;
/** @var PluginManager */
private $pluginManager = null;
@ -1852,6 +1854,13 @@ class Server{
}
public function forceShutdown(){
if($this->hasStopped){
return;
}
try{
$this->hasStopped = true;
$this->shutdown();
if($this->rcon instanceof RCON){
$this->rcon->stop();
@ -1877,15 +1886,21 @@ class Server{
}
HandlerList::unregisterAll();
$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());
}
}
/**

View File

@ -144,7 +144,7 @@ class ServerScheduler{
}
$this->tasks = [];
$this->asyncTaskStorage = [];
$this->asyncPool->shutdown();
//$this->asyncPool->shutdown();
$this->asyncTasks = 0;
$this->queue = new ReversePriorityQueue();
$this->asyncPool = new \Pool(self::$WORKERS, AsyncWorker::class);