Hxhong opened a new issue #5055:
URL: https://github.com/apache/apisix/issues/5055


   ### Issue description
   
   I add app-online-check plugin in /usr/local/apisix/apisix/plugins.
   app-online-check.lua
   `
   local core = require("apisix.core")
   local redis_new = require("resty.redis").new
   local hmac = require "resty.hmac"
   local str = require "resty.string"
   
   local schema = {
       type = "object",
       properties = {
           redis_host = {
               type = "string",
               minLength = 2
           },
           redis_port = {
               type = "integer",
               minimum = 1
           },
           redis_password = {
               type = "string",
               minLength = 0
           },
           redis_timeout = {
               type = "integer",
               minimum = 1
           },
           ignores = {
               type = "array",
               items = {
                   type = "string"
               }
           }
       },
       additionalProperties = false,
       required = { "redis_host" }
   }
   
   local plugin_name = "app-online-check"
   
   local _M = {
       version = 0.1,
       priority = 4002,
       type = 'check',
       name = plugin_name,
       schema = schema,
   }
   
   
   -- Check the schema defined in this plugin.
   function _M.check_schema(conf)
       conf.redis_port = conf.redis_port or 6379
       conf.redis_timeout = conf.redis_timeout or 1000
   
       if not core.schema.check(schema, conf) then
           return false
       end
   
       local ignores = conf.ignores or {}
       conf.ignores = {}
       for i, v in ipairs(ignores) do
           conf.ignores[v] = i
       end
   
       return true
   end
   
   -- The entrance
   function _M.access(conf, ctx)
       core.log.error("ngx.ctx.api_ctx.route_id: "..ngx.ctx.api_ctx.route_id)
   end
   
   return _M
   `
   
   And add it to config.yaml.
   `
   plugins:
    - app-online-check
   `
   
   Then I run 'apisix reload', the error log shows below
   
![image](https://user-images.githubusercontent.com/42258295/133195232-6859fb81-39c4-449b-aa1f-6c5e1299ecab.png)
   
   But it can run in version 1.5 with the same plugin config.
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.6
   - OS (cmd: `uname -a`): CentOS Linux release 7.4.1708 (Core)
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): 
openresty/1.19.3.2
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API): 
3.4.0
   - apisix-dashboard version, if have:
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`):
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to