eee
This commit is contained in:
@@ -307,7 +307,7 @@ class FileWatcher extends AbstractProcess implements OnProcessInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->reloadWorkers()) {
|
if (!$this->reloadWorkers()) {
|
||||||
di(StdoutLogger::class)->println('reload server failed: master pid not found or signal failed');
|
di(StdoutLogger::class)->println('reload server failed: Server->reload() failed, and master pid fallback not found or signal failed');
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
$this->reloading = false;
|
$this->reloading = false;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class HotReload extends AbstractProcess
|
|||||||
|
|
||||||
$this->clear();
|
$this->clear();
|
||||||
if (!$this->reloadWorkers()) {
|
if (!$this->reloadWorkers()) {
|
||||||
di(StdoutLogger::class)->println('reload server failed: master pid not found or signal failed');
|
di(StdoutLogger::class)->println('reload server failed: Server->reload() failed, and master pid fallback not found or signal failed');
|
||||||
}
|
}
|
||||||
$this->addListen();
|
$this->addListen();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ trait ReloadWorkers
|
|||||||
*/
|
*/
|
||||||
private function reloadWorkers(): bool
|
private function reloadWorkers(): bool
|
||||||
{
|
{
|
||||||
|
if ($this->reloadByServerInstance()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$pid = $this->getMasterPid();
|
$pid = $this->getMasterPid();
|
||||||
if ($pid === null) {
|
if ($pid === null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -22,6 +26,25 @@ trait ReloadWorkers
|
|||||||
return Process::kill($pid, SIGUSR1);
|
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
|
private function getMasterPid(): ?int
|
||||||
{
|
{
|
||||||
if (self::$cachedMasterPid !== null && $this->isCachedMasterPid(self::$cachedMasterPid)) {
|
if (self::$cachedMasterPid !== null && $this->isCachedMasterPid(self::$cachedMasterPid)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user