This commit is contained in:
2021-11-19 10:31:26 +08:00
parent b1a5db0a6b
commit 6ac2c73a8c
+2 -4
View File
@@ -132,20 +132,18 @@ class HotReload extends Command
public function trigger_reload() public function trigger_reload()
{ {
$this->logger->warning('change reload'); $this->logger->warning('change reload');
if ($this->process instanceof Process && Process::kill($this->process->pid, 0)) {
$pid = file_get_contents(storage('.swoole.pid')); $pid = file_get_contents(storage('.swoole.pid'));
if (!empty($pid) && Process::kill($pid, 0)) { if (!empty($pid) && Process::kill($pid, 0)) {
Process::kill($pid, SIGTERM); Process::kill($pid, SIGTERM);
} }
// Process::kill($this->process->pid, SIGTERM);
$this->process->exit(0);
Process::wait(true); Process::wait(true);
} if (!$this->process) {
$this->process = new Process(function (Process $process) { $this->process = new Process(function (Process $process) {
$process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]); $process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]);
}); });
$this->process->start(); $this->process->start();
} }
}
} }