This commit is contained in:
2021-11-19 03:51:41 +08:00
parent d3ed35e948
commit 5d91b61f83
+2 -22
View File
@@ -92,7 +92,6 @@ class HotReload extends Command
#[NoReturn] public function onSignal($data) #[NoReturn] public function onSignal($data)
{ {
$pid = file_get_contents(storage('.swoole.pid')); $pid = file_get_contents(storage('.swoole.pid'));
var_dump($pid);
if (!empty($pid) && Process::kill($pid, 0)) { if (!empty($pid) && Process::kill($pid, 0)) {
Process::kill($pid, SIGTERM); Process::kill($pid, SIGTERM);
} }
@@ -100,23 +99,6 @@ class HotReload extends Command
} }
/**
* @throws Exception
*/
public function onExit()
{
$data = Coroutine::waitSignal(SIGTERM | SIGKILL, -1);
if ($data) {
$pid = file_get_contents(storage('.swoole.pid'));
if (!empty($pid) && Process::kill($pid, 0)) {
Process::kill($pid, SIGTERM);
}
$this->stop();
$this->source = NULL;
}
}
/** /**
* @throws Exception * @throws Exception
*/ */
@@ -126,11 +108,8 @@ class HotReload extends Command
proc_terminate($this->source); proc_terminate($this->source);
while (proc_get_status($this->source)['running']) { while (proc_get_status($this->source)['running']) {
Coroutine::sleep(1); Coroutine::sleep(1);
var_dump(proc_get_status($this->source)['running']);
} }
var_dump(proc_get_status($this->source)['running']);
proc_close($this->source); proc_close($this->source);
var_dump('isClose.');
$this->source = NULL; $this->source = NULL;
} }
} }
@@ -165,8 +144,9 @@ class HotReload extends Command
if (!empty($pid) && Process::kill($pid, 0)) { if (!empty($pid) && Process::kill($pid, 0)) {
Process::kill($pid, SIGTERM); Process::kill($pid, SIGTERM);
} }
$this->stop();
Coroutine::create(function () { Coroutine::create(function () {
proc_open('php ' . APP_PATH . '/kiri.php sw:server restart', [], $pipes); $this->source = proc_open('php ' . APP_PATH . '/kiri.php sw:server restart', [], $pipes);
}); });
} }