少了local balancer定义是笔误。这个没有影响。
print("before require ngx.balancer")
local balancer = require("ngx.balancer")
print("after require ngx.balancer")
balancer.set_current_peer(host, port)
日志:
2016/04/13 09:27:00 [notice] 11982#0: *1 [lua] balancer_by_lua:12: before require ngx.balancer while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8081"
2016/04/13 09:27:00 [notice] 11981#0: signal 20 (SIGCHLD) received
2016/04/13 09:27:00 [alert] 11981#0: worker process 11982 exited on signal 11
2016/04/13 09:27:00 [notice] 11981#0: start worker process 11986
2016/04/13 09:27:00 [notice] 11981#0: signal 23 (SIGIO) received
2016/04/13 09:27:00 [notice] 11981#0: signal 23 (SIGIO) received