V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
awanganddong
V2EX  ?  Lua

openresty + lua 这个地方怎么写

  •  
  •   awanganddong · 322 天前 · 1178 次点击
    这是一个创建于 322 天前的主题,其中的信息可能已经有所发展或是发生改变。

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    lua-resty-upstream-healthcheck lua-resty-balancer

    这两个插件是负载均衡和健康检测。组合到一块我不知道怎么写了。

        upstream webserver {
            server 127.0.0.1:12354;
            server 127.0.0.1:12355;
            server 127.0.0.1:12356 backup;
        }
        
      upstream webserver {
            server 127.0.0.1;
            balancer_by_lua_block {
                local b = require "ngx.balancer"
                local swrr_up = package.loaded.my_swrr_up
    
                -- Note that SWRR picks the first server randomly
                local server = swrr_up:find()
                assert(b.set_current_peer(server))
            }
       }  
        
    
    awanganddong
        1
    awanganddong  
    OP
       322 天前   ?? 1
    lua-resty-upstream-healthcheck 和 lua-resty-balancer 不兼容
    好像是 init_worker_by_lua_block 执行顺序先于 balancer_by_lua_block 。

    可以试试这个库: https://github.com/upyun/lua-resty-checkups
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   975 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 21:09 · PVG 05:09 · LAX 14:09 · JFK 17:09
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com