改名
This commit is contained in:
@@ -86,6 +86,7 @@ class HotReload extends Command
|
|||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->initCore();
|
$this->initCore();
|
||||||
|
|
||||||
$this->trigger_reload();
|
$this->trigger_reload();
|
||||||
|
|
||||||
Timer::tick(1000, fn() => $this->healthCheck());
|
Timer::tick(1000, fn() => $this->healthCheck());
|
||||||
@@ -124,17 +125,35 @@ class HotReload extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->driver->clear();
|
$this->driver->clear();
|
||||||
|
$this->stopServer();
|
||||||
|
$this->stopManager();
|
||||||
|
while ($ret = Process::wait(true)) {
|
||||||
|
echo "PID={$ret['pid']}\n";
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function stopServer()
|
||||||
|
{
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function stopManager()
|
||||||
|
{
|
||||||
if ($this->process && Process::kill($this->process->pid, 0)) {
|
if ($this->process && Process::kill($this->process->pid, 0)) {
|
||||||
Process::kill($this->process->pid) && Process::wait(true);
|
Process::kill($this->process->pid) && Process::wait(true);
|
||||||
}
|
}
|
||||||
while ($ret = Process::wait(true)) {
|
|
||||||
echo "PID={$ret['pid']}\n";
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,17 +164,21 @@ class HotReload extends Command
|
|||||||
*/
|
*/
|
||||||
public function trigger_reload()
|
public function trigger_reload()
|
||||||
{
|
{
|
||||||
$this->logger->warning('change reload');
|
if ($this->int == 1) {
|
||||||
$pid = $this->process?->pid;
|
return;
|
||||||
if ($pid && Process::kill($pid, 0)) {
|
|
||||||
Process::kill($pid) && Process::wait(true);
|
|
||||||
}
|
}
|
||||||
$this->process = null;
|
$this->int = 1;
|
||||||
$process = new Process(function (Process $process) {
|
$this->logger->warning('change reload');
|
||||||
|
|
||||||
|
$this->stopServer();
|
||||||
|
$this->stopManager();
|
||||||
|
|
||||||
|
$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"]);
|
||||||
});
|
});
|
||||||
$process->start();
|
|
||||||
$this->process = $process;
|
$this->process->start();
|
||||||
|
$this->int = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user