Compare commits

..

6 Commits

Author SHA1 Message Date
as2252258 a7db58d7e4 改名 2021-11-24 17:07:35 +08:00
as2252258 87e4bfdbec 改名 2021-11-24 17:07:13 +08:00
as2252258 ee761817bf 1 2021-11-21 01:30:49 +08:00
as2252258 4a4b7db651 1 2021-11-20 02:33:53 +08:00
as2252258 905427bccc 1 2021-11-20 02:30:13 +08:00
as2252258 68ee0244a2 1 2021-11-20 02:27:25 +08:00
5 changed files with 13 additions and 91 deletions
+5 -4
View File
@@ -21,16 +21,17 @@
"ext-xml": "*",
"ext-curl": "*",
"ext-openssl": "*",
"symfony/console": "^v5.3",
"symfony/console": "v5.3.10",
"psr/log": "1.*",
"ext-sockets": "*",
"ext-pcntl": "*",
"ext-posix": "*",
"composer-runtime-api": "^2.0",
"swiftmailer/swiftmailer": "^6.0",
"swiftmailer/swiftmailer": "v6.3.*",
"psr/container": "^2.0",
"psr/http-server-middleware": "^1.0",
"game-worker/kiri-event": "v1.0"
"psr/http-server-middleware": "1.0.1",
"game-worker/kiri-event": "v1.0",
"ext-inotify": "*"
},
"autoload": {
"psr-4": {
+8 -9
View File
@@ -4,6 +4,7 @@ namespace Kiri\FileListen;
use Exception;
use Swoole\Event;
use Swoole\Timer;
class Inotify
{
@@ -14,6 +15,9 @@ class Inotify
private array $watchFiles = [];
protected bool $isReloading = FALSE;
protected int $cid;
const IG_DIR = [APP_PATH . 'commands', APP_PATH . '.git', APP_PATH . '.gitee'];
@@ -60,7 +64,7 @@ class Inotify
if (!($events = inotify_read($this->inotify))) {
return;
}
if ($this->process->isReloading) {
if ($this->isReloading) {
return;
}
@@ -71,7 +75,8 @@ class Inotify
}
//非重启类型
if (str_ends_with($ev['name'], '.php')) {
$this->reload();
Timer::after(3000, fn()=>$this->reload());
$this->isReloading = TRUE;
}
}
}
@@ -81,19 +86,13 @@ class Inotify
*/
public function reload()
{
if ($this->process->isReloading) {
return;
}
$this->process->isReloading = true;
$this->process->trigger_reload();
$this->clearWatch();
foreach ($this->dirs as $root) {
$this->watch($root);
}
$this->process->int = -1;
$this->process->isReloading = FALSE;
$this->isReloading = FALSE;
}
-8
View File
@@ -1,8 +0,0 @@
<?php
namespace Kiri\Proxy;
abstract class AProxy
{
}
-53
View File
@@ -1,53 +0,0 @@
<?php
namespace Kiri\Proxy;
use Annotation\Aspect;
use Http\Handler\Handler;
use Kiri\Di\NoteManager;
use Kiri\IAspect;
use Kiri\Kiri;
/**
*
*/
class AspectProxy extends AProxy implements ProxyInterface
{
/**
* @param Handler $executor
* @return mixed
*/
public function proxy(Handler $executor): mixed
{
if ($executor->callback instanceof \Closure) {
return call_user_func($executor->callback, ...$executor->params);
}
$controller = Kiri::getDi()->get($executor->callback[0]);
$aspect = $this->getAspect($executor->callback);
if (!is_null($aspect)) {
$aspect->before();
$result = $aspect->invoke([$controller, $executor->callback[1]], $executor->params);
$aspect->after($result);
} else {
$result = call_user_func([$controller, $executor->callback[1]]);
}
return $result;
}
/**
* @param array $executor
* @return ?IAspect
*/
protected function getAspect(array $executor): ?IAspect
{
$aspect = NoteManager::getSpecify_annotation(Aspect::class, $executor[0], $executor[1]);
if (!is_null($aspect)) {
$aspect = Kiri::getDi()->get($aspect->aspect);
}
return $aspect;
}
}
-17
View File
@@ -1,17 +0,0 @@
<?php
namespace Kiri\Proxy;
use Http\Handler\Handler;
interface ProxyInterface
{
/**
* @param Handler $executor
* @return mixed
*/
public function proxy(Handler $executor): mixed;
}