eee
This commit is contained in:
+15
-27
@@ -4,6 +4,9 @@ namespace Kiri\Server\Abstracts;
|
||||
|
||||
use Kiri\Di\Inject\Container;
|
||||
use Kiri\Error\StdoutLogger;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Router\Router;
|
||||
use Kiri\Server\Events\OnWorkerStart;
|
||||
use Kiri\Server\ServerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swoole\Event;
|
||||
@@ -51,6 +54,15 @@ class HotReload extends AbstractProcess
|
||||
protected bool $reloading = false;
|
||||
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
di(EventProvider::class)->on(OnWorkerStart::class, [di(Router::class), 'scan_build_route']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -78,10 +90,9 @@ class HotReload extends AbstractProcess
|
||||
$this->addListen();
|
||||
Event::add($this->pipe, function () use ($process) {
|
||||
$read = inotify_read($this->pipe);
|
||||
|
||||
var_dump($read);
|
||||
|
||||
$this->reload();
|
||||
if (count($read) > 0) {
|
||||
$this->reload();
|
||||
}
|
||||
});
|
||||
Event::cycle(function (): void {
|
||||
if ($this->isStop()) {
|
||||
@@ -103,14 +114,10 @@ class HotReload extends AbstractProcess
|
||||
$this->reloading = true;
|
||||
|
||||
$this->clear();
|
||||
|
||||
di(ServerInterface::class)->reload();
|
||||
|
||||
$this->addListen();
|
||||
|
||||
$this->reloading = false;
|
||||
|
||||
var_dump(inotify_queue_len($this->pipe));
|
||||
}
|
||||
|
||||
|
||||
@@ -147,25 +154,6 @@ class HotReload extends AbstractProcess
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $directory
|
||||
* @return void
|
||||
*/
|
||||
public function reWatch(int $directory): void
|
||||
{
|
||||
if (isset($this->watches[$directory])) {
|
||||
inotify_rm_watch($this->pipe, $directory);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $directory
|
||||
* @return void
|
||||
|
||||
Reference in New Issue
Block a user