Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a5205e9a1 | |||
| 471f7a92bb | |||
| 429ffe561c | |||
| 27cdf5082f | |||
| 4c3751ca4d | |||
| 5f1eaf8239 |
@@ -20,7 +20,7 @@ use Kiri\Crontab\CrontabProviders;
|
||||
use Kiri\Events\OnAfterCommandExecute;
|
||||
use Kiri\Events\OnBeforeCommandExecute;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\FileListen\FileChangeCustomProcess;
|
||||
use Kiri\FileListen\HotReload;
|
||||
use ReflectionException;
|
||||
use Server\ServerProviders;
|
||||
use stdClass;
|
||||
@@ -119,7 +119,7 @@ class Application extends BaseApplication
|
||||
$container = Kiri::getDi();
|
||||
|
||||
$console = $container->get(ConsoleApplication::class);
|
||||
$console->add($container->get(FileChangeCustomProcess::class));
|
||||
$console->add($container->get(HotReload::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ class Application extends BaseApplication
|
||||
private function enableFileChange(Command $class, $input, $output): void
|
||||
{
|
||||
fire(new OnBeforeCommandExecute());
|
||||
if (!($class instanceof FileChangeCustomProcess)) {
|
||||
if (!($class instanceof HotReload)) {
|
||||
scan_directory(directory('app'), 'App');
|
||||
}
|
||||
$class->run($input, $output);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class FileChangeCustomProcess extends Command
|
||||
class HotReload extends Command
|
||||
{
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ class Inotify
|
||||
|
||||
/**
|
||||
* @param array $dirs
|
||||
* @param FileChangeCustomProcess $process
|
||||
* @param HotReload $process
|
||||
*/
|
||||
public function __construct(protected array $dirs, public FileChangeCustomProcess $process)
|
||||
public function __construct(protected array $dirs, public HotReload $process)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ class Scaner
|
||||
|
||||
/**
|
||||
* @param array $dirs
|
||||
* @param FileChangeCustomProcess $process
|
||||
* @param HotReload $process
|
||||
*/
|
||||
public function __construct(protected array $dirs, public FileChangeCustomProcess $process)
|
||||
public function __construct(protected array $dirs, public HotReload $process)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ defined('TASK_PATH') or define('TASK_PATH', APP_PATH . 'app/Async/');
|
||||
defined('LISTENER_PATH') or define('LISTENER_PATH', APP_PATH . 'app/Listener/');
|
||||
defined('KAFKA_PATH') or define('KAFKA_PATH', APP_PATH . 'app/Kafka/');
|
||||
defined('RPC_CLIENT_PATH') or define('RPC_CLIENT_PATH', APP_PATH . 'app/Client/Rpc/');
|
||||
defined('MODEL_PATH') or define('MODEL_PATH', APP_PATH . 'app/Models/');
|
||||
defined('MODEL_PATH') or define('MODEL_PATH', APP_PATH . 'app/Model/');
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -220,6 +220,13 @@ class Pool extends Component
|
||||
return;
|
||||
}
|
||||
while (static::$_connections[$name]->length() > 0) {
|
||||
if (static::$_connections[$name] instanceof Channel)
|
||||
{
|
||||
if (!Context::inCoroutine())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$client = static::$_connections[$name]->pop();
|
||||
if ($client instanceof StopHeartbeatCheck) {
|
||||
$client->stopHeartbeatCheck();
|
||||
|
||||
+4
-4
@@ -30,11 +30,11 @@ class Gii
|
||||
|
||||
private InputInterface $input;
|
||||
|
||||
public string $modelPath = APP_PATH . 'app/Models/';
|
||||
public string $modelNamespace = 'App\\Models\\';
|
||||
public string $modelPath = APP_PATH . 'app/Model/';
|
||||
public string $modelNamespace = 'App\\Model\\';
|
||||
|
||||
public string $controllerPath = APP_PATH . 'app/Http/Controllers/';
|
||||
public string $controllerNamespace = 'App\\Controllers\\';
|
||||
public string $controllerPath = APP_PATH . 'app/Http/Controller/';
|
||||
public string $controllerNamespace = 'App\\Controller\\';
|
||||
|
||||
|
||||
public static array $createSqls = [];
|
||||
|
||||
@@ -24,11 +24,11 @@ abstract class GiiBase
|
||||
|
||||
protected InputInterface $input;
|
||||
|
||||
public string $modelPath = APP_PATH . 'app/Models/';
|
||||
public string $modelNamespace = 'App\Models\\';
|
||||
public string $modelPath = APP_PATH . 'app/Model/';
|
||||
public string $modelNamespace = 'App\Model\\';
|
||||
|
||||
public string $controllerPath = APP_PATH . 'app/Http/Controllers/';
|
||||
public string $controllerNamespace = 'App\\Controllers\\';
|
||||
public string $controllerPath = APP_PATH . 'app/Http/Controller/';
|
||||
public string $controllerNamespace = 'App\\Controller\\';
|
||||
|
||||
public ?string $module = null;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ use Kiri\Core\Json;
|
||||
use Database\Connection;
|
||||
use Database\Annotation\Get;
|
||||
use Database\Annotation\Set;
|
||||
use Annotation\Model\Relation;
|
||||
use Database\Relation;
|
||||
use Database\Model;
|
||||
' . PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Process;
|
||||
|
||||
interface OnProcessInterface
|
||||
{
|
||||
|
||||
public function handle();
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Process;
|
||||
|
||||
abstract class Process implements OnProcessInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var \Swoole\Process
|
||||
*/
|
||||
protected \Swoole\Process $process;
|
||||
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected mixed $redirect_stdin_and_stdout = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $pipe_type = SOCK_DGRAM;
|
||||
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $enable_coroutine = true;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $name = '';
|
||||
|
||||
/**
|
||||
* @return \Swoole\Process
|
||||
*/
|
||||
public function getProcess(): \Swoole\Process
|
||||
{
|
||||
return $this->process;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRedirectStdinAndStdout(): mixed
|
||||
{
|
||||
return $this->redirect_stdin_and_stdout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPipeType(): int
|
||||
{
|
||||
return $this->pipe_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnableCoroutine(): bool
|
||||
{
|
||||
return $this->enable_coroutine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \Swoole\Process $process
|
||||
*/
|
||||
public function start(\Swoole\Process $process)
|
||||
{
|
||||
$this->process = $process;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Process;
|
||||
|
||||
require_once 'OnProcessInterface.php';
|
||||
require_once 'Process.php';
|
||||
|
||||
use function Co\run;
|
||||
|
||||
class TestProcess extends Process
|
||||
{
|
||||
|
||||
|
||||
protected string $name = 'test process';
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public function onStart()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// TODO: Implement doWhile() method.
|
||||
}
|
||||
|
||||
|
||||
public function onShutdown()
|
||||
{
|
||||
// TODO: Implement onShutdown() method.
|
||||
}
|
||||
}
|
||||
|
||||
$array = [];
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$class = new TestProcess();
|
||||
$process = new \Swoole\Process([$class, 'start'], $class->getRedirectStdinAndStdout(),
|
||||
$class->getPipeType(), $class->isEnableCoroutine());
|
||||
$process->start();
|
||||
|
||||
array_push($array, $process);
|
||||
}
|
||||
run(function () use ($array) {
|
||||
|
||||
foreach ($array as $value) {
|
||||
var_dump($value->getCallback());
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user