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