This commit is contained in:
2022-05-31 11:43:06 +08:00
parent 0ad17ae4c5
commit f94a8a3792
+10 -6
View File
@@ -91,16 +91,20 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
* @param OnBeforeShutdown $beforeShutdown * @param OnBeforeShutdown $beforeShutdown
* @return void * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface|ConfigException
*/ */
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void
{ {
$doneList = $this->manager->doneList();
$agent = $this->container->get(Agent::class); $agent = $this->container->get(Agent::class);
foreach ($doneList as $value) { $value = Config::get("rpc.consul", []);
$agent->service->deregister($value['config']['ID']); if (empty($value)) {
$agent->checks->deregister($value['config']['Check']['CheckId']); return;
} }
$this->logger->debug("disconnect consul.");
$agent->service->deregister($value['ID']);
$agent->checks->deregister($value['Check']['CheckId']);
} }