eee
This commit is contained in:
+16
-6
@@ -70,17 +70,14 @@ class HotReload extends AbstractProcess
|
||||
public function process(Process|null $process): void
|
||||
{
|
||||
$this->pipe = inotify_init();
|
||||
|
||||
foreach (config('reload.listen') as $value) {
|
||||
$this->readDirectory($value);
|
||||
}
|
||||
while (!$this->isStop()) {
|
||||
$read = inotify_read($this->pipe);
|
||||
foreach ($read as $item) {
|
||||
$this->reWatch($item['wd']);
|
||||
if (!empty($read)) {
|
||||
$this->reload();
|
||||
}
|
||||
|
||||
$this->reload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +92,18 @@ class HotReload extends AbstractProcess
|
||||
}
|
||||
$this->reloading = true;
|
||||
|
||||
foreach ($this->watches as $key => $watch) {
|
||||
inotify_rm_watch($this->pipe, $key);
|
||||
}
|
||||
|
||||
\Kiri::getLogger()->info('reloading server, please waite.');
|
||||
|
||||
di(ServerInterface::class)->reload();
|
||||
|
||||
foreach (config('reload.listen') as $value) {
|
||||
$this->readDirectory($value);
|
||||
}
|
||||
|
||||
$this->reloading = false;
|
||||
}
|
||||
|
||||
@@ -126,7 +131,12 @@ class HotReload extends AbstractProcess
|
||||
if (isset($this->watches[$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