eee
This commit is contained in:
+16
-6
@@ -70,19 +70,16 @@ class HotReload extends AbstractProcess
|
|||||||
public function process(Process|null $process): void
|
public function process(Process|null $process): void
|
||||||
{
|
{
|
||||||
$this->pipe = inotify_init();
|
$this->pipe = inotify_init();
|
||||||
|
|
||||||
foreach (config('reload.listen') as $value) {
|
foreach (config('reload.listen') as $value) {
|
||||||
$this->readDirectory($value);
|
$this->readDirectory($value);
|
||||||
}
|
}
|
||||||
while (!$this->isStop()) {
|
while (!$this->isStop()) {
|
||||||
$read = inotify_read($this->pipe);
|
$read = inotify_read($this->pipe);
|
||||||
foreach ($read as $item) {
|
if (!empty($read)) {
|
||||||
$this->reWatch($item['wd']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->reload();
|
$this->reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,10 +92,18 @@ class HotReload extends AbstractProcess
|
|||||||
}
|
}
|
||||||
$this->reloading = true;
|
$this->reloading = true;
|
||||||
|
|
||||||
|
foreach ($this->watches as $key => $watch) {
|
||||||
|
inotify_rm_watch($this->pipe, $key);
|
||||||
|
}
|
||||||
|
|
||||||
\Kiri::getLogger()->info('reloading server, please waite.');
|
\Kiri::getLogger()->info('reloading server, please waite.');
|
||||||
|
|
||||||
di(ServerInterface::class)->reload();
|
di(ServerInterface::class)->reload();
|
||||||
|
|
||||||
|
foreach (config('reload.listen') as $value) {
|
||||||
|
$this->readDirectory($value);
|
||||||
|
}
|
||||||
|
|
||||||
$this->reloading = false;
|
$this->reloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +131,12 @@ class HotReload extends AbstractProcess
|
|||||||
if (isset($this->watches[$directory])) {
|
if (isset($this->watches[$directory])) {
|
||||||
inotify_rm_watch($this->pipe, $directory);
|
inotify_rm_watch($this->pipe, $directory);
|
||||||
|
|
||||||
inotify_add_watch($this->pipe, $this->watches[$directory], IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE);
|
$path = $this->watches[$directory];
|
||||||
|
unset($this->watches[$directory]);
|
||||||
|
|
||||||
|
$data = inotify_add_watch($this->pipe, $path, IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE);
|
||||||
|
|
||||||
|
$this->watches[$data] = $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user