变更
This commit is contained in:
+7
-3
@@ -28,7 +28,6 @@ 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;
|
||||||
@@ -96,14 +95,19 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
|||||||
*/
|
*/
|
||||||
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void
|
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown): void
|
||||||
{
|
{
|
||||||
$agent = $this->container->get(Catalog::class);
|
if ($beforeShutdown->server->worker_id != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$agent = $this->container->get(Agent::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']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user