111
This commit is contained in:
@@ -56,7 +56,7 @@ class FileChangeCustomProcess extends Command
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// TODO: Implement onHandler() method.
|
||||
// set_error_handler([$this, 'onErrorHandler']);
|
||||
set_error_handler([$this, 'onErrorHandler']);
|
||||
|
||||
$this->dirs = Config::get('inotify', [APP_PATH . 'app']);
|
||||
if (!extension_loaded('inotify')) {
|
||||
@@ -64,11 +64,10 @@ class FileChangeCustomProcess extends Command
|
||||
} else {
|
||||
$driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]);
|
||||
}
|
||||
$this->trigger_reload(0);
|
||||
Coroutine::create(function () use ($driver) {
|
||||
$driver->start(Coroutine::getCid());
|
||||
});
|
||||
return 0;
|
||||
|
||||
$driver->start();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +91,7 @@ class FileChangeCustomProcess extends Command
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function trigger_reload($cid)
|
||||
public function trigger_reload()
|
||||
{
|
||||
Kiri::getDi()->get(Logger::class)->warning('change reload');
|
||||
|
||||
|
||||
@@ -31,15 +31,15 @@ class Inotify
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function start($cid)
|
||||
public function start()
|
||||
{
|
||||
$this->cid = $cid;
|
||||
$this->inotify = inotify_init();
|
||||
$this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE;
|
||||
foreach ($this->dirs as $dir) {
|
||||
if (!is_dir($dir)) continue;
|
||||
$this->watch($dir);
|
||||
}
|
||||
$this->process->trigger_reload();
|
||||
Event::add($this->inotify, [$this, 'check']);
|
||||
Event::wait();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class Inotify
|
||||
public function reload()
|
||||
{
|
||||
$this->process->isReloading = true;
|
||||
$this->process->trigger_reload($this->cid);
|
||||
$this->process->trigger_reload();
|
||||
|
||||
$this->clearWatch();
|
||||
foreach ($this->dirs as $root) {
|
||||
|
||||
Reference in New Issue
Block a user