Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e43775b04 | |||
| dd4e9be06a | |||
| 73b01c288b | |||
| f4f48ebad7 | |||
| ef95f912cb | |||
| 8bbb6adcc7 | |||
| a855765365 |
@@ -138,17 +138,16 @@ class HotReload extends Command
|
||||
public function trigger_reload()
|
||||
{
|
||||
$this->logger->warning('change reload');
|
||||
// $pid = file_get_contents(storage('.swoole.pid'));
|
||||
// if (!empty($pid) && Process::kill($pid, 0)) {
|
||||
// Process::kill($pid, SIGTERM);
|
||||
// }
|
||||
if ($this->process && Process::kill($this->process->pid, 0)) {
|
||||
Process::kill($this->process->pid) && Process::wait(true);
|
||||
}
|
||||
$this->process = new Process(function (Process $process) {
|
||||
$pid = $this->process?->pid;
|
||||
$process = new Process(function (Process $process) {
|
||||
$process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]);
|
||||
});
|
||||
$this->process->start();
|
||||
$process->start();
|
||||
if ($pid && Process::kill($pid, 0)) {
|
||||
Process::kill($pid) && Process::wait(true);
|
||||
}
|
||||
$this->process = null;
|
||||
$this->process = $process;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,21 +51,19 @@ class Inotify
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始监听
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* 开始监听
|
||||
* @throws Exception
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
if (!($events = inotify_read($this->inotify))) {
|
||||
return;
|
||||
}
|
||||
if ($this->process->isReloading) {
|
||||
if (!$this->process->isReloadingOut) {
|
||||
$this->process->isReloadingOut = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$LISTEN_TYPE = [IN_CREATE, IN_DELETE, IN_MODIFY, IN_MOVED_TO, IN_MOVED_FROM];
|
||||
foreach ($events as $ev) {
|
||||
if (!in_array($ev['mask'], $LISTEN_TYPE)) {
|
||||
@@ -73,7 +71,6 @@ class Inotify
|
||||
}
|
||||
//非重启类型
|
||||
if (str_ends_with($ev['name'], '.php')) {
|
||||
sleep(2);
|
||||
$this->reload();
|
||||
}
|
||||
}
|
||||
@@ -84,7 +81,12 @@ class Inotify
|
||||
*/
|
||||
public function reload()
|
||||
{
|
||||
if ($this->process->isReloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->process->isReloading = true;
|
||||
|
||||
$this->process->trigger_reload();
|
||||
$this->clearWatch();
|
||||
foreach ($this->dirs as $root) {
|
||||
@@ -92,7 +94,6 @@ class Inotify
|
||||
}
|
||||
$this->process->int = -1;
|
||||
$this->process->isReloading = FALSE;
|
||||
$this->process->isReloadingOut = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ class Scaner
|
||||
*/
|
||||
public function timerReload()
|
||||
{
|
||||
if ($this->process->isReloading) {
|
||||
return;
|
||||
}
|
||||
$this->process->isReloading = true;
|
||||
$this->process->trigger_reload();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user