当前位置: 代码迷 >> 综合 >> openresty resty.upstream.healthcheck模块使用
  详细解决方案

openresty resty.upstream.healthcheck模块使用

热度:68   发布时间:2023-12-12 02:52:10.0

openresty upstream健康检查,Lua代码实现:

resty.upstream.healthcheck

#lua_shared_dict healthcheck 1m;

#lua_socket_log_errors off;

#init_worker_by_lua_block {

# local hc = require "resty.upstream.healthcheck"

# local ok, err = hc.spawn_checker {

# shm = "healthcheck",

# upstream = "rp_10_10_10_10_80cn",

# type = "http",

# http_req = "GET /status HTTP/1.0\r\nHost: rp_10_10_10_1-0_80cn\r\n\r\n",

# interval = 2000,

# timeout = 3000,

# fall = 3,

# rise = 2,

# valid_statuses = {200, 302, 404},

# concurrency = 10,

# }

 

# if not ok then

# ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)

# return

# end

#}

#location /status {

# access_log off;

# default_type text/plain;

# content_by_lua_block {

# local hc = require "resty.upstream.healthcheck"

# ngx.say("Nginx Worker PID: ", ngx.worker.pid())

# ngx.print(hc.status_page())

# }

#}

  相关解决方案