This commit is contained in:
2022-05-31 11:54:06 +08:00
parent f94a8a3792
commit 6715743843
+3 -4
View File
@@ -28,6 +28,7 @@ use Kiri\Server\Events\OnWorkerStart;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Kiri\Consul\Catalog\Catalog;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use ReflectionException; use ReflectionException;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -95,16 +96,14 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
*/ */
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void
{ {
$agent = $this->container->get(Agent::class); $agent = $this->container->get(Catalog::class);
$value = Config::get("rpc.consul", []); $value = Config::get("rpc.consul", []);
if (empty($value)) { if (empty($value)) {
return; return;
} }
$this->logger->debug("disconnect consul."); $this->logger->debug("disconnect consul.");
$agent->deregister(["node" => $value['ID']]);
$agent->service->deregister($value['ID']);
$agent->checks->deregister($value['Check']['CheckId']);
} }