modify mysql result

This commit is contained in:
2022-04-29 14:46:45 +08:00
parent 021076cf51
commit af768725d8
3 changed files with 121 additions and 106 deletions
-2
View File
@@ -59,8 +59,6 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
set_env('environmental', Kiri::WORKER); set_env('environmental', Kiri::WORKER);
$this->setProcessName(sprintf('Worker Process[%d].%d', $server->worker_pid, $workerId)); $this->setProcessName(sprintf('Worker Process[%d].%d', $server->worker_pid, $workerId));
$dispatch->dispatch(new OnWorkerStart($server, $workerId)); $dispatch->dispatch(new OnWorkerStart($server, $workerId));
$this->router->scan_build_route();
} else { } else {
set_env('environmental', Kiri::TASK); set_env('environmental', Kiri::TASK);
$this->setProcessName(sprintf('Tasker Process[%d].%d', $server->worker_pid, $workerId)); $this->setProcessName(sprintf('Tasker Process[%d].%d', $server->worker_pid, $workerId));
+8 -2
View File
@@ -11,10 +11,14 @@ use Swoole\Event;
use Swoole\Process; use Swoole\Process;
use Swoole\Timer; use Swoole\Timer;
/**
*
*/
class Inotify extends BaseProcess class Inotify extends BaseProcess
{ {
private mixed $inotify; private mixed $inotify = null;
private mixed $events; private mixed $events;
private array $watchFiles = []; private array $watchFiles = [];
@@ -81,7 +85,6 @@ class Inotify extends BaseProcess
} }
/** /**
* @throws Exception * @throws Exception
*/ */
@@ -100,6 +103,9 @@ class Inotify extends BaseProcess
public function clear() public function clear()
{ {
if (is_null($this->inotify)) {
return;
}
Event::del($this->inotify); Event::del($this->inotify);
Event::exit(); Event::exit();
} }
+15 -4
View File
@@ -22,6 +22,8 @@ use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use ReflectionException; use ReflectionException;
use Swoole\Coroutine; use Swoole\Coroutine;
use Kiri\Events\EventProvider;
use Kiri\Server\Events\OnWorkerStart;
defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid'); defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid');
@@ -45,6 +47,7 @@ class Server extends HttpService
* @param ContainerInterface $container * @param ContainerInterface $container
* @param ProcessManager $processManager * @param ProcessManager $processManager
* @param EventDispatch $eventDispatch * @param EventDispatch $eventDispatch
* @param EventProvider $eventProvider
* @param Router $router * @param Router $router
* @param array $config * @param array $config
* @throws Exception * @throws Exception
@@ -54,6 +57,7 @@ class Server extends HttpService
public ContainerInterface $container, public ContainerInterface $container,
public ProcessManager $processManager, public ProcessManager $processManager,
public EventDispatch $eventDispatch, public EventDispatch $eventDispatch,
public EventProvider $eventProvider,
public Router $router, public Router $router,
array $config = []) array $config = [])
{ {
@@ -67,13 +71,13 @@ class Server extends HttpService
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function init() public function init(): void
{ {
$this->container->mapping(ResponseInterface::class, Response::class); $this->container->mapping(ResponseInterface::class, Response::class);
$this->container->mapping(RequestInterface::class, Request::class); $this->container->mapping(RequestInterface::class, Request::class);
$enable_coroutine = Config::get('servers.settings.enable_coroutine', false); $enable_coroutine = Config::get('servers.settings.enable_coroutine', false);
if ($enable_coroutine != true) { if (!$enable_coroutine) {
return; return;
} }
Coroutine::set([ Coroutine::set([
@@ -111,7 +115,14 @@ class Server extends HttpService
$this->manager->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'], $rpcService['mode'], $rpcService); $this->manager->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'], $rpcService['mode'], $rpcService);
} }
// $this->process[] = Inotify::class; $reload = Config::get('reload.hot', false);
if ($reload !== false) {
$this->eventProvider->on(OnWorkerStart::class, [$this->router, 'scan_build_route']);
$this->process[] = Inotify::class;
} else {
$this->router->scan_build_route();
}
$processes = array_merge($this->process, Config::get('processes', [])); $processes = array_merge($this->process, Config::get('processes', []));
@@ -130,7 +141,7 @@ class Server extends HttpService
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
* @throws Exception * @throws Exception
*/ */
public function shutdown() public function shutdown(): void
{ {
$configs = Config::get('server', [], true); $configs = Config::get('server', [], true);
foreach ($this->manager->sortService($configs['ports'] ?? []) as $config) { foreach ($this->manager->sortService($configs['ports'] ?? []) as $config) {