From a8cd5d59fc9e91a852a05e545cdab12ba0270326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 29 Oct 2021 11:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RpcJsonp.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/RpcJsonp.php b/src/RpcJsonp.php index 4db0d90..7322e52 100644 --- a/src/RpcJsonp.php +++ b/src/RpcJsonp.php @@ -6,8 +6,10 @@ use Annotation\Annotation; use Annotation\Inject; use Http\Handler\Router; use Kiri\Abstracts\Component; +use Kiri\Abstracts\Config; use Kiri\Consul\Agent; use Kiri\Di\NoteManager; +use Kiri\Exception\ConfigException; use Kiri\Kiri; use Server\SInterface\OnCloseInterface; use Server\SInterface\OnConnectInterface; @@ -60,22 +62,27 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa } + /** + * @throws ConfigException + */ public function register() { + $config = Config::get('rpc'); + $agent = Kiri::getDi()->get(Agent::class); $agent->service->register([ - "ID" => "redis1", + "ID" => $config['name'] ?? 'test-name', "Name" => "redis", "Tags" => ["primary", "v1"], - "Address" => "127.0.0.1", - "Port" => 8000, + "Address" => Kiri::localhost(), + "Port" => $config['port'], "Meta" => [ "redis_version" => "4.0" ], "EnableTagOverride" => false, "Check" => [ "DeregisterCriticalServiceAfter" => "90m", -// "Args" => ["/usr/local/bin/check_redis.py"], + // "Args" => ["/usr/local/bin/check_redis.py"], "Interval" => "10s", "Timeout" => "5s" ],