modify plugin name

This commit is contained in:
2022-02-23 18:12:57 +08:00
parent 1cdb8aceac
commit 09dd2443c7
3 changed files with 11 additions and 10 deletions
+4 -4
View File
@@ -5,7 +5,6 @@ namespace Kiri\FileListen;
use Exception;
use Kiri;
use Kiri\Abstracts\Config;
use Kiri\Annotation\Inject;
use Kiri\Core\Json;
use Kiri\Error\StdoutLoggerInterface;
use Kiri\Exception\ConfigException;
@@ -39,7 +38,6 @@ class HotReload extends Command
public Inotify|Scaner $driver;
#[Inject(StdoutLoggerInterface::class)]
public StdoutLoggerInterface $logger;
@@ -55,6 +53,8 @@ class HotReload extends Command
protected function configure()
{
$this->setName('sw:wather')->setDescription('server start');
$this->logger = Kiri::getDi()->get(StdoutLoggerInterface::class);
}
@@ -67,9 +67,9 @@ class HotReload extends Command
set_error_handler([$this, 'errorHandler']);
$this->dirs = Config::get('inotify', [APP_PATH . 'app']);
if (!extension_loaded('inotify')) {
$this->driver = Kiri::getDi()->make(Scaner::class, [$this->dirs, $this]);
$this->driver = make(Scaner::class, [$this->dirs, $this, $this->logger]);
} else {
$this->driver = Kiri::getDi()->make(Inotify::class, [$this->dirs, $this]);
$this->driver = make(Inotify::class, [$this->dirs, $this, $this->logger]);
}
$this->clearOtherService();
$this->setProcessName();
+5 -4
View File
@@ -27,8 +27,10 @@ class Inotify
/**
* @param array $dirs
* @param HotReload $process
* @param StdoutLoggerInterface $logger
*
*/
public function __construct(protected array $dirs, public HotReload $process)
public function __construct(protected array $dirs, public HotReload $process, public StdoutLoggerInterface $logger)
{
set_error_handler([$this, 'error']);
set_exception_handler([$this, 'error']);
@@ -103,7 +105,7 @@ class Inotify
*/
public function reload($path)
{
\Kiri::getDi()->get(StdoutLoggerInterface::class)->warning('file change');
$this->logger->warning('file change');
$this->process->trigger_reload($path);
$this->process->int = -1;
@@ -137,8 +139,7 @@ class Inotify
{
//目录不存在
if (!is_dir($dir)) {
logger()->addError("[$dir] is not a directory.");
return false;
return $this->logger->addError("[$dir] is not a directory.");
}
//避免重复监听
if (isset($this->watchFiles[$dir])) {
+2 -2
View File
@@ -17,7 +17,7 @@ class Scaner
* @param array $dirs
* @param HotReload $process
*/
public function __construct(protected array $dirs, public HotReload $process)
public function __construct(protected array $dirs, public HotReload $process, public StdoutLoggerInterface $logger)
{
}
@@ -113,7 +113,7 @@ class Scaner
{
$this->isReloading = TRUE;
\Kiri::getDi()->get(StdoutLoggerInterface::class)->warning('file change');
$this->logger->warning('file change');
$this->process->trigger_reload($path);