eee
This commit is contained in:
@@ -14,6 +14,10 @@ trait ReloadWorkers
|
||||
*/
|
||||
private function reloadWorkers(): bool
|
||||
{
|
||||
if ($this->reloadByServerInstance()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$pid = $this->getMasterPid();
|
||||
if ($pid === null) {
|
||||
return false;
|
||||
@@ -22,6 +26,25 @@ trait ReloadWorkers
|
||||
return Process::kill($pid, SIGUSR1);
|
||||
}
|
||||
|
||||
private function reloadByServerInstance(): bool
|
||||
{
|
||||
try {
|
||||
$server = function_exists('di') ? di(\Kiri\Server\ServerInterface::class) : null;
|
||||
} catch (\Throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_object($server) || !method_exists($server, 'reload')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return $server->reload() !== false;
|
||||
} catch (\Throwable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function getMasterPid(): ?int
|
||||
{
|
||||
if (self::$cachedMasterPid !== null && $this->isCachedMasterPid(self::$cachedMasterPid)) {
|
||||
|
||||
Reference in New Issue
Block a user