改名
This commit is contained in:
@@ -391,7 +391,7 @@ class Server extends HttpService
|
||||
if (!isset($settings['pid_file'])) {
|
||||
$settings['pid_file'] = PID_PATH;
|
||||
}
|
||||
$this->debug(sprintf('Check listen %s::%d -> ok', $config['host'], $config['port']));
|
||||
$this->debug(Snowflake::listen($config));
|
||||
|
||||
$this->onLoadWebsocketHandler();
|
||||
if ($this->baseServer instanceof Http) {
|
||||
|
||||
+24
-3
@@ -59,9 +59,9 @@ class Service extends Component
|
||||
$mode = $service['mode'] ?? SWOOLE_SOCK_TCP6;
|
||||
|
||||
if (Snowflake::port_already($service['port'])) {
|
||||
throw new Exception(sprintf('Port %s::%d is already.', $service['host'], $service['port']));
|
||||
throw new Exception($this->already($service));
|
||||
}
|
||||
$this->debug(sprintf('Port %s::%d is already.', $service['host'], $service['port']));
|
||||
$this->debug(Snowflake::listen($service));
|
||||
|
||||
$rpcServer = $server->addlistener($service['host'], $service['port'], $mode);
|
||||
$rpcServer->set([
|
||||
@@ -72,7 +72,28 @@ class Service extends Component
|
||||
'open_http_protocol' => false,
|
||||
'open_websocket_protocol' => false,
|
||||
]);
|
||||
$router->addPortListen($service['port'], function () use ($service, $mode) {
|
||||
$this->listenPort($service, $mode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $service
|
||||
* @return string
|
||||
*/
|
||||
private function already($service): string
|
||||
{
|
||||
return sprintf('Port %s::%d is already.', $service['host'], $service['port']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $service
|
||||
* @param $mode
|
||||
* @throws Exception
|
||||
*/
|
||||
private function listenPort($service, $mode)
|
||||
{
|
||||
router()->addPortListen($service['port'], function () use ($service, $mode) {
|
||||
try {
|
||||
/** @var Request $request */
|
||||
$request = Context::getContext('request');
|
||||
|
||||
@@ -102,6 +102,16 @@ class Snowflake
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $service
|
||||
* @return string
|
||||
*/
|
||||
#[Pure] public static function listen($service): string
|
||||
{
|
||||
return sprintf('Check listen %s::%d -> ok', $service['host'], $service['port']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $className
|
||||
* @param array $construct
|
||||
|
||||
Reference in New Issue
Block a user