You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/31 06:44:43 UTC
[GitHub] [apisix] membphis commented on issue #3169: chore: cache the error message when create new `healthcheck` instance
membphis commented on issue #3169:
URL: https://github.com/apache/apisix/issues/3169#issuecomment-752865195
The patch, it maybe useful for you. welcome PR ^_^
```patch
diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index d80cb676..c644bdc3 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -87,11 +87,15 @@ local function create_checker(upstream, healthcheck_parent)
if healthcheck == nil then
healthcheck = require("resty.healthcheck")
end
- local checker = healthcheck.new({
+ local checker, err = healthcheck.new({
name = "upstream#" .. healthcheck_parent.key,
shm_name = "upstream-healthcheck",
checks = upstream.checks,
})
+ if not checker then
+ core.log.error("fail to create healthcheck instance: ", err)
+ return
+ end
local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org