This commit is contained in:
2023-12-12 10:56:42 +08:00
parent 3d89612a8e
commit 4ebb7e9686
8 changed files with 16 additions and 16 deletions
-1
View File
@@ -3,7 +3,6 @@
namespace Kiri\Server\Abstracts;
use Exception;
use Kiri;
use Kiri\Exception\ConfigException;
use Kiri\Exception\NotFindClassException;
use Kiri\Server\Config as SConfig;
-1
View File
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Kiri\Server\Handler;
use Exception;
use Kiri;
use Kiri\Di\Inject\Container;
use Kiri\Di\Context;
use Kiri\Di\Interface\ResponseEmitterInterface;
+2 -3
View File
@@ -2,10 +2,9 @@
namespace Kiri\Server\Handler;
use Kiri;
use Kiri\Di\Inject\Container;
use Kiri\Error\StdoutLogger;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use ReflectionException;
use Kiri\Server\Abstracts\Server;
@@ -36,7 +35,7 @@ class OnServer extends Server
*/
public function onStart(SServer $server): void
{
\Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
foreach (config('server.ports') as $value) {
$this->logger->alert('Listen ' . $value['type'] . ' address ' . $value['host'] . '::' . $value['port']);
}
+2 -1
View File
@@ -45,7 +45,8 @@ class HotReload extends BaseProcess
*/
public function getName(): string
{
return '[' . \config('id', 'system-service') . '].hot.load'; // TODO: Change the autogenerated stub
// TODO: Change the autogenerated stub
return '[' . \config('id', 'system-service') . '].hot.load';
}
+4 -3
View File
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function config;
defined('ROUTER_TYPE_HTTP') or define('ROUTER_TYPE_HTTP', 'http');
defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid');
@@ -99,7 +100,7 @@ class ServerCommand extends Command
*/
protected function stop(): int
{
$configs = \config('server', []);
$configs = config('server', []);
$instances = $this->manager->sortService($configs['ports'] ?? []);
foreach ($instances as $config) {
$this->state->exit($config->port);
@@ -117,13 +118,13 @@ class ServerCommand extends Command
protected function start(InputInterface $input): int
{
$daemon = (int)$input->getOption('daemon');
if (\config('reload.hot', false) === true) {
if (config('reload.hot', false) === true) {
$this->manager->addProcess(HotReload::class);
} else {
$this->router->scan_build_route();
}
$this->manager->addProcess(config('processes', []));
$this->manager->initCoreServers(\config('server', []), $daemon);
$this->manager->initCoreServers(config('server', []), $daemon);
$this->manager->start();
return 1;
}
-1
View File
@@ -8,7 +8,6 @@ use Kiri\Abstracts\Providers;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Application;
use Kiri;
/**
* Class DatabasesProviders
+2 -1
View File
@@ -6,6 +6,7 @@ use Exception;
use Kiri\Abstracts\Component;
use Kiri\Server\Abstracts\TraitServer;
use Swoole\Process;
use function config;
class State extends Component
{
@@ -21,7 +22,7 @@ class State extends Component
*/
public function init(): void
{
$this->servers = \config('server.ports');
$this->servers = config('server.ports');
}
+2 -1
View File
@@ -3,6 +3,7 @@
namespace Kiri\Server\Task;
use Exception;
use Kiri;
use Kiri\Server\Constant;
use ReflectionException;
@@ -50,7 +51,7 @@ class Task
* @param int $src_worker_id
* @param mixed $data
* @return mixed
* @throws ReflectionException
* @throws ReflectionException|Exception
*/
public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): mixed
{