Hello!
On Wed, Feb 18, 2015 at 1:34 PM, Rollin Crittendon wrote:
> [C]: in function 'sleep'
> /usr/local/openresty/lualib/resty/lock.lua:153: in function 'lock'
> 2015/02/18 16:28:41 [error] 75487#0: init_worker_by_lua_file error:
> /usr/local/openresty/lualib/resty/lock.lua:153: API disabled in the context
> of init_worker_by_lua*
>
Yes, lua-resty-lock might sleep but the init_worker_by_lua context
cannot sleep. One common workaround is to use a 0-delay timer via
ngx.timer.at(). The lua-resty-upstream-healthcheck library uses this
technique:
https://github.com/openresty/lua-resty-upstream-healthcheck
Regards,
-agentzh