变更
This commit is contained in:
@@ -75,6 +75,8 @@ class AsyncServer implements ServerInterface
|
|||||||
$this->addListener(instance(SConfig::class, [], $rpcService));
|
$this->addListener(instance(SConfig::class, [], $rpcService));
|
||||||
}
|
}
|
||||||
$this->processManager->batch(Config::get('processes', []));
|
$this->processManager->batch(Config::get('processes', []));
|
||||||
|
|
||||||
|
$this->onSignal(Config::get('signal', []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+29
-29
@@ -38,13 +38,13 @@ defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid');
|
|||||||
*/
|
*/
|
||||||
class Server extends HttpService
|
class Server extends HttpService
|
||||||
{
|
{
|
||||||
|
|
||||||
private mixed $daemon = 0;
|
private mixed $daemon = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param State $state
|
* @param State $state
|
||||||
* @param CoroutineServer $manager
|
* @param AsyncServer $manager
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @param ProcessManager $processManager
|
* @param ProcessManager $processManager
|
||||||
* @param EventDispatch $dispatch
|
* @param EventDispatch $dispatch
|
||||||
@@ -54,7 +54,7 @@ class Server extends HttpService
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(public State $state,
|
public function __construct(public State $state,
|
||||||
public CoroutineServer $manager,
|
public AsyncServer $manager,
|
||||||
public ContainerInterface $container,
|
public ContainerInterface $container,
|
||||||
public ProcessManager $processManager,
|
public ProcessManager $processManager,
|
||||||
public EventDispatch $dispatch,
|
public EventDispatch $dispatch,
|
||||||
@@ -64,8 +64,8 @@ class Server extends HttpService
|
|||||||
{
|
{
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -77,15 +77,15 @@ class Server extends HttpService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Coroutine::set([
|
Coroutine::set([
|
||||||
'hook_flags' => (SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL) ^ SWOOLE_HOOK_BLOCKING_FUNCTION,
|
'hook_flags' => (SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL) ^ SWOOLE_HOOK_BLOCKING_FUNCTION,
|
||||||
'enable_deadlock_check' => FALSE,
|
'enable_deadlock_check' => FALSE,
|
||||||
'exit_condition' => function () {
|
'exit_condition' => function () {
|
||||||
return Coroutine::stats()['coroutine_num'] === 0;
|
return Coroutine::stats()['coroutine_num'] === 0;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $process
|
* @param $process
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -94,8 +94,8 @@ class Server extends HttpService
|
|||||||
{
|
{
|
||||||
$this->processManager->add($process);
|
$this->processManager->add($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -109,8 +109,8 @@ class Server extends HttpService
|
|||||||
$this->manager->initCoreServers(Config::get('server', [], true), $this->daemon);
|
$this->manager->initCoreServers(Config::get('server', [], true), $this->daemon);
|
||||||
$this->manager->start();
|
$this->manager->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -121,8 +121,8 @@ class Server extends HttpService
|
|||||||
$this->provider->on(OnWorkerStart::class, [$this, 'setWorkerName']);
|
$this->provider->on(OnWorkerStart::class, [$this, 'setWorkerName']);
|
||||||
$this->provider->on(OnTaskerStart::class, [$this, 'setTaskerName']);
|
$this->provider->on(OnTaskerStart::class, [$this, 'setTaskerName']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param OnWorkerStart $onWorkerStart
|
* @param OnWorkerStart $onWorkerStart
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -134,11 +134,11 @@ class Server extends HttpService
|
|||||||
}
|
}
|
||||||
$prefix = sprintf('Worker Process[%d].%d', $onWorkerStart->server->worker_pid, $onWorkerStart->workerId);
|
$prefix = sprintf('Worker Process[%d].%d', $onWorkerStart->server->worker_pid, $onWorkerStart->workerId);
|
||||||
set_env('environmental', Kiri::WORKER);
|
set_env('environmental', Kiri::WORKER);
|
||||||
|
|
||||||
Kiri::setProcessName($prefix);
|
Kiri::setProcessName($prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param OnTaskerStart $onWorkerStart
|
* @param OnTaskerStart $onWorkerStart
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -150,11 +150,11 @@ class Server extends HttpService
|
|||||||
}
|
}
|
||||||
$prefix = sprintf('Tasker Process[%d].%d', $onWorkerStart->server->worker_pid, $onWorkerStart->workerId);
|
$prefix = sprintf('Tasker Process[%d].%d', $onWorkerStart->server->worker_pid, $onWorkerStart->workerId);
|
||||||
set_env('environmental', Kiri::TASK);
|
set_env('environmental', Kiri::TASK);
|
||||||
|
|
||||||
Kiri::setProcessName($prefix);
|
Kiri::setProcessName($prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -171,8 +171,8 @@ class Server extends HttpService
|
|||||||
$this->router->scan_build_route();
|
$this->router->scan_build_route();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -188,8 +188,8 @@ class Server extends HttpService
|
|||||||
}
|
}
|
||||||
$this->dispatch->dispatch(new OnShutdown());
|
$this->dispatch->dispatch(new OnShutdown());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -199,8 +199,8 @@ class Server extends HttpService
|
|||||||
{
|
{
|
||||||
return $this->state->isRunner();
|
return $this->state->isRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $daemon
|
* @param $daemon
|
||||||
* @return Server
|
* @return Server
|
||||||
|
|||||||
Reference in New Issue
Block a user