resty/http.lua:100: API disabled in the context of init_worker_by_lua*
stack traceback:
[C]: in function 'ngx_socket_tcp'
lualib/resty/http.lua:100: in function 'new'
想用lua实现发送http请求watch consul上的服务注册信息,当注册信息有变化时watcher返回,使用根据最新的注册信息更新nginx upstream。伪代码表示如下:while true: r = send_http_request(url) # block until registry changed new_upstream = build_upstream(r) replace_upstream(new_upstream) lua-resty-http结合 lua-upstream-nginx-module看上去好像能搞定,但这个循环应该写在什么context下?
在 2016年12月2日,下午1:26,Huabin Zheng <huabi...@gmail.com> 写道:我用resty.http在init_worker_by_lua中执行这个while loop,结果报错说resty/http.lua:100: API disabled in the context of init_worker_by_lua*stack traceback: [C]: in function 'ngx_socket_tcp' lualib/resty/http.lua:100: in function 'new'On Thursday, December 1, 2016 at 1:05:17 PM UTC+8, Huabin Zheng wrote:想用lua实现发送http请求watch consul上的服务注册信息,当注册信息有变化时watcher返回,使用根据最新的注册信息更新nginx upstream。伪代码表示如下:while true: r = send_http_request(url) # block until registry changed new_upstream = build_upstream(r) replace_upstream(new_upstream) lua-resty-http结合 lua-upstream-nginx-module看上去好像能搞定,但这个循环应该写在什么context下?-- --
我用resty.http在init_worker_by_lua中执行这个while loop,结果报错说 resty/http.lua:100: API disabled in the context of init_worker_by_lua* stack traceback: [C]: in function 'ngx_socket_tcp' lualib/resty/http.lua:100: in function 'new'On Thursday, December 1, 2016 at 1:05:17 PM UTC+8, Huabin Zheng wrote:想用lua实现发送http请求watch consul上的服务注册信息,当注册信息有变化时watcher返回,使用根据最新的注册信息更新nginx upstream。伪代码表示如下:while true: r = send_http_request(url) # block until registry changed new_upstream = build_upstream(r) replace_upstream(new_upstream) lua-resty-http结合 lua-upstream-nginx-module看上去好像能搞定,但这个循环应该写在什么context下? --
Hello正确的做法是:在 init_worker 创建 timer,在 timer 内使用 cosocket在 2016年12月2日 下午1:26,Huabin Zheng <huabin...@gmail.com>写道:我用resty.http在init_worker_by_lua中执行这个while loop,结果报错说 resty/http.lua:100: API disabled in the context of init_worker_by_lua* stack traceback: [C]: in function 'ngx_socket_tcp' lualib/resty/http.lua:100: in function 'new'On Thursday, December 1, 2016 at 1:05:17 PM UTC+8, Huabin Zheng wrote:想用lua实现发送http请求watch consul上的服务注册信息,当注册信息有变化时watcher返回,使用根据最新的注册信息更新nginx upstream。伪代码表示如下:while true: r = send_http_request(url) # block until registry changed new_upstream = build_upstream(r) replace_upstream(new_upstream) lua-resty-http结合 lua-upstream-nginx-module看上去好像能搞定,但这个循环应该写在什么context下? --
你好,我也在做类似的事情,我想咨询一下你们的做法。1.你们不同项目的不同upstream注册到consul的时候是怎么组织关系的啊?比如一个server 一个upstream吗?2.watch ,部分具体是怎么检测的。比如,watch 某个server 吗?谢谢你在 2016年12月1日星期四 UTC+8下午1:05:17,Huabin Zheng写道:想用lua实现发送http请求watch consul上的服务注册信息,当注册信息有变化时watcher返回,使用根据最新的注册信息更新nginx upstream。伪代码表示如下:while true: r = send_http_request(url) # block until registry changed new_upstream = build_upstream(r) replace_upstream(new_upstream) lua-resty-http结合 lua-upstream-nginx-module看上去好像能搞定,但这个循环应该写在什么context下? --