如何优雅的注销 Consul 服务实例 #3014
huangdijia
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
|
pre-stop.sh 需要跟随服务一起定义嘛 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
问题背景
A、B 两个 Service 在同时滚动更新的时候,遇到过 A Service 原 IP(假设是 10.0.0.1) 被分配给了 B Service,导致 Consul 认为 10.0.0.1 这个 IP 依然属于 A Service,在远程调用的时候就会报
Method not found。目前 hyperf/service-governance 只支持服务注册,未支持服务注销。
解决思路
于是我根据思路 3 去实现,并做成了扩展包 huangdijia/hyperf-service-governance-auto-deregister,可以一键接入。
与 K8S 配合
当我使用 Ctrl+C 终止服务的时候,看到了我期待的注销服务日志,欣喜若狂!但是到了 K8S 滚动更新的时候,并未如我所料,百度了一下,原来是因为 K8S 滚动更新的时候并未向业务进程发终止信号。
有是一波百度,找到了 https://cloud.tencent.com/developer/article/1638716 ,可通过
向业务进程发送终止信号。
完美!
Beta Was this translation helpful? Give feedback.
All reactions