改名
This commit is contained in:
@@ -17,7 +17,7 @@ use Http\Context\HttpHeaders;
|
||||
use Http\Context\HttpParams;
|
||||
use Http\Context\Response;
|
||||
use Http\Route\Router;
|
||||
use Http\Server;
|
||||
use Server\Server;
|
||||
use Http\Shutdown;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kafka\KafkaProvider;
|
||||
|
||||
@@ -11,7 +11,7 @@ use Http\Client\Curl;
|
||||
use Http\Context\Response;
|
||||
use Http\HttpFilter;
|
||||
use Http\Route\Router;
|
||||
use Http\Server;
|
||||
use Server\Server;
|
||||
use Http\Shutdown;
|
||||
use Kiri\Crontab\Producer;
|
||||
use Kiri\Async;
|
||||
|
||||
@@ -15,9 +15,9 @@ use Console\Console;
|
||||
use Console\ConsoleProviders;
|
||||
use Database\DatabasesProviders;
|
||||
use Exception;
|
||||
use Http\Command;
|
||||
use Server\ServerCommand;
|
||||
use Http\Context\Response;
|
||||
use Http\ServerProviders;
|
||||
use Server\ServerProviders;
|
||||
use Kiri\Abstracts\BaseApplication;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Abstracts\Kernel;
|
||||
@@ -240,7 +240,7 @@ class Application extends BaseApplication
|
||||
*/
|
||||
private function enableFileChange($class): void
|
||||
{
|
||||
if (!($class instanceof Command)) {
|
||||
if (!($class instanceof ServerCommand)) {
|
||||
scan_directory(directory('app'), 'App');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Http;
|
||||
namespace Server;
|
||||
|
||||
use Annotation\Inject;
|
||||
use Exception;
|
||||
@@ -12,9 +12,7 @@ use Kiri\Error\LoggerProcess;
|
||||
use Kiri\Events\EventDispatch;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Rpc\Service;
|
||||
use ReflectionException;
|
||||
use Server\Events\OnShutdown;
|
||||
use Server\ServerManager;
|
||||
use Swoole\Runtime;
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Http;
|
||||
namespace Server;
|
||||
|
||||
|
||||
use Annotation\Inject;
|
||||
use Exception;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
use ReflectionException;
|
||||
@@ -15,6 +14,7 @@ use Server\Events\OnBeforeWorkerStart;
|
||||
use Server\Events\OnWorkerStart;
|
||||
use Server\Worker\OnServerWorker;
|
||||
use Server\Worker\OnWorkerStart as WorkerDispatch;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -23,7 +23,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
* Class Command
|
||||
* @package Http
|
||||
*/
|
||||
class Command extends \Symfony\Component\Console\Command\Command
|
||||
class ServerCommand extends Command
|
||||
{
|
||||
|
||||
|
||||
@@ -52,40 +52,40 @@ class Command extends \Symfony\Component\Console\Command\Command
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @return string
|
||||
* @throws ConfigException
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$manager = Kiri::app()->getServer();
|
||||
$manager->setDaemon($input->getArgument('daemon'));
|
||||
if (!in_array($input->getArgument('action'), self::ACTIONS)) {
|
||||
$output->write('I don\'t know what I want to do.');
|
||||
try {
|
||||
$manager = Kiri::app()->getServer();
|
||||
$manager->setDaemon($input->getArgument('daemon'));
|
||||
if (!in_array($input->getArgument('action'), self::ACTIONS)) {
|
||||
throw new Exception('I don\'t know what I want to do.');
|
||||
}
|
||||
if ($manager->isRunner() && $input->getArgument('action') == 'start') {
|
||||
throw new Exception('Service is running. Please use restart.');
|
||||
}
|
||||
$manager->shutdown();
|
||||
if ($input->getArgument('action') == 'stop') {
|
||||
throw new Exception('shutdown success');
|
||||
}
|
||||
$this->generate_runtime_builder($manager);
|
||||
} catch (\Throwable $throwable) {
|
||||
$output->write($throwable->getMessage());
|
||||
} finally {
|
||||
return 1;
|
||||
}
|
||||
if ($manager->isRunner() && $input->getArgument('action') == 'start') {
|
||||
$output->write('Service is running. Please use restart.');
|
||||
return 1;
|
||||
}
|
||||
$manager->shutdown();
|
||||
if ($input->getArgument('action') == 'stop') {
|
||||
$output->write('shutdown success');
|
||||
return 1;
|
||||
}
|
||||
return $this->generate_runtime_builder($manager);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $manager
|
||||
* @return mixed
|
||||
* @return void
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
private function generate_runtime_builder($manager): mixed
|
||||
private function generate_runtime_builder($manager): void
|
||||
{
|
||||
exec(PHP_BINARY . ' ' . APP_PATH . 'kiri.php runtime:builder');
|
||||
|
||||
@@ -93,8 +93,6 @@ class Command extends \Symfony\Component\Console\Command\Command
|
||||
$this->eventProvider->on(OnWorkerStart::class, [di(WorkerDispatch::class), 'dispatch']);
|
||||
|
||||
$manager->start();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Http;
|
||||
namespace Server;
|
||||
|
||||
|
||||
use Exception;
|
||||
@@ -28,7 +28,7 @@ class ServerProviders extends Providers
|
||||
$container = Kiri::getDi();
|
||||
|
||||
$console = $container->get(\Symfony\Component\Console\Application::class);
|
||||
$console->add($container->get(Command::class));
|
||||
$console->add($container->get(ServerCommand::class));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user