This commit is contained in:
2021-09-02 11:13:11 +08:00
parent d605b4b218
commit 4e2bb41358
3 changed files with 249 additions and 224 deletions
+3 -3
View File
@@ -21,6 +21,7 @@
"ext-xml": "*", "ext-xml": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-openssl": "*", "ext-openssl": "*",
"symfony/console": "^2.4 || ^3.0 || ^4.0",
"amphp/amp": "v1.2.2", "amphp/amp": "v1.2.2",
"psr/log": "1.*", "psr/log": "1.*",
"ext-sockets": "*", "ext-sockets": "*",
@@ -34,7 +35,8 @@
"psr/cache": "^3.0", "psr/cache": "^3.0",
"psr/http-client": "^1.0", "psr/http-client": "^1.0",
"psr/simple-cache": "^1.0", "psr/simple-cache": "^1.0",
"game-worker/kiri-event": "v1.0" "game-worker/kiri-event": "v1.0",
"linkorb/etcd-php": "^1.6"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@@ -49,7 +51,5 @@
"error.php", "error.php",
"function.php" "function.php"
] ]
},
"require-dev": {
} }
} }
+23 -10
View File
@@ -17,11 +17,9 @@ use Database\DatabasesProviders;
use Exception; use Exception;
use Http\Command; use Http\Command;
use Http\Context\Response; use Http\Context\Response;
use Http\Server;
use Http\ServerProviders; use Http\ServerProviders;
use Kiri\Abstracts\BaseApplication; use Kiri\Abstracts\BaseApplication;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Abstracts\Input;
use Kiri\Abstracts\Kernel; use Kiri\Abstracts\Kernel;
use Kiri\Crontab\CrontabProviders; use Kiri\Crontab\CrontabProviders;
use Kiri\Exception\NotFindClassException; use Kiri\Exception\NotFindClassException;
@@ -31,6 +29,8 @@ use Server\ResponseInterface;
use stdClass; use stdClass;
use Swoole\Process; use Swoole\Process;
use Swoole\Timer; use Swoole\Timer;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
/** /**
* Class Init * Class Init
@@ -191,27 +191,40 @@ class Application extends BaseApplication
public function register(string $command) public function register(string $command)
{ {
/** @var Console $abstracts */ /** @var Console $abstracts */
$abstracts = $this->get('console'); // $abstracts = $this->get('console');
$abstracts->register($command); // $abstracts->register($command);
$console = di(\Symfony\Component\Console\Application::class);
$console->add(di($command));
} }
/** /**
* @param Input $argv * @param array $argv
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function execute(Input $argv): void public function execute(array $argv): void
{ {
try { try {
$this->register(Runtime::class); $this->register(Runtime::class);
$manager = Kiri::app()->get('console'); $input = new ArgvInput($argv);
$class = $manager->setParameters($argv)->search();
$this->enableFileChange($class); $console = di(\Symfony\Component\Console\Application::class);
$command = $console->find($input->getFirstArgument());
$data = $this->getBuilder($manager->exec($class)); // /** @var Console $manager */
// $manager = Kiri::app()->get('console');
// $class = $manager->setParameters($argv)->search();
$command->run($input, $output = new ConsoleOutput());
$this->enableFileChange($command);
$data = $output->getStream();
// $data = $this->getBuilder($manager->exec($class));
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$data = $this->getBuilder(jTraceEx($exception)); $data = $this->getBuilder(jTraceEx($exception));
} finally { } finally {
+18 -6
View File
@@ -9,17 +9,19 @@ use Exception;
use Kiri\Abstracts\Input; use Kiri\Abstracts\Input;
use Kiri\Events\EventProvider; use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Kiri\Exception\NotFindClassException;
use Kiri\Kiri; use Kiri\Kiri;
use ReflectionException;
use Server\Events\OnBeforeWorkerStart; use Server\Events\OnBeforeWorkerStart;
use Server\Events\OnWorkerStart;
use Server\Worker\OnServerWorker; use Server\Worker\OnServerWorker;
use Server\Worker\OnWorkerStart as WorkerDispatch; use Server\Worker\OnWorkerStart as WorkerDispatch;
use Server\Events\OnWorkerStart;
/** /**
* Class Command * Class Command
* @package Http * @package Http
*/ */
class Command extends \Console\Command class Command extends \Symfony\Component\Console\Command\Command
{ {
public string $command = 'sw:server'; public string $command = 'sw:server';
@@ -32,12 +34,22 @@ class Command extends \Console\Command
/** /**
* @var \Kiri\Events\EventProvider * @var EventProvider
*/ */
#[Inject(EventProvider::class)] #[Inject(EventProvider::class)]
public EventProvider $eventProvider; public EventProvider $eventProvider;
/**
*
*/
protected function configure()
{
$this->setName('swoole')
->setDescription('server start|stop|reload|restart');
}
/** /**
* @param Input $dtl * @param Input $dtl
* @return string * @return string
@@ -65,10 +77,10 @@ class Command extends \Console\Command
/** /**
* @param $manager * @param $manager
* @return mixed * @return mixed
* @throws \Kiri\Exception\NotFindClassException * @throws NotFindClassException
* @throws \ReflectionException * @throws ReflectionException
*/ */
private function generate_runtime_builder($manager) private function generate_runtime_builder($manager): mixed
{ {
exec(PHP_BINARY . ' ' . APP_PATH . 'kiri.php runtime:builder'); exec(PHP_BINARY . ' ' . APP_PATH . 'kiri.php runtime:builder');