eee
This commit is contained in:
+12
-7
@@ -22,6 +22,12 @@ class HotReload extends AbstractProcess
|
|||||||
protected bool $enable_coroutine = false;
|
protected bool $enable_coroutine = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $watches = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@@ -64,16 +70,14 @@ 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 $key => $value) {
|
$this->readFile($value);
|
||||||
$this->readDirectory($value);
|
|
||||||
}
|
}
|
||||||
while (!$this->isStop()) {
|
while (!$this->isStop()) {
|
||||||
$read = inotify_read($this->pipe);
|
$read = inotify_read($this->pipe);
|
||||||
var_dump($read);
|
|
||||||
|
|
||||||
foreach ($read as $item) {
|
foreach ($read as $item) {
|
||||||
$this->reWatch($item['name']);
|
$this->reWatch($this->watches[$item['wd']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->reload();
|
$this->reload();
|
||||||
@@ -105,9 +109,10 @@ class HotReload extends AbstractProcess
|
|||||||
*/
|
*/
|
||||||
public function readFile(string $directory): void
|
public function readFile(string $directory): void
|
||||||
{
|
{
|
||||||
var_dump($directory);
|
|
||||||
if (str_ends_with($directory, '.php') === true) {
|
if (str_ends_with($directory, '.php') === true) {
|
||||||
inotify_add_watch($this->pipe, $directory, IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE);
|
$wd = inotify_add_watch($this->pipe, $directory, IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE);
|
||||||
|
|
||||||
|
$this->watches[$wd] = $directory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user