Skip to content

Commit

Permalink
Using internal request instead of external request in node-status plu…
Browse files Browse the repository at this point in the history
…gin. (apache#1109)
  • Loading branch information
agile6v authored Feb 7, 2020
1 parent 5fff97d commit 6cc3654
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lua/apisix/admin/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function _M.check_schema(plugins_conf)
core.json.delay_encode(plugin_conf, true))
local plugin_obj = local_plugins[name]
if not plugin_obj then
return false, "unknow plugin [" .. name .. "]"
return false, "unknown plugin [" .. name .. "]"
end

if plugin_obj.check_schema then
Expand All @@ -67,7 +67,7 @@ function _M.stream_check_schema(plugins_conf)
": ", core.json.delay_encode(plugin_conf, true))
local plugin_obj = stream_local_plugins[name]
if not plugin_obj then
return false, "unknow plugin [" .. name .. "]"
return false, "unknown plugin [" .. name .. "]"
end

if plugin_obj.check_schema then
Expand Down
9 changes: 2 additions & 7 deletions lua/apisix/plugins/node-status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
local core = require("apisix.core")
local ngx = ngx
local re_gmatch = ngx.re.gmatch
local ngx_capture = ngx.location.capture
local plugin_name = "node-status"
local apisix_id = core.id.get()
local ipairs = ipairs
Expand All @@ -37,13 +38,7 @@ local ngx_statu_items = {


local function collect()
local res, err = core.http.request_self("/apisix/nginx_status", {
keepalive = false,
})
if not res then
return 500, "failed to fetch nginx status: " .. err
end

local res = ngx_capture("/apisix/nginx_status")
if res.status ~= 200 then
return res.status
end
Expand Down

0 comments on commit 6cc3654

Please sign in to comment.