openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.23k stars 2.02k forks source link

init_by_lua during Nginx config test #2311

Open Rockybilly opened 3 months ago

Rockybilly commented 3 months ago

So the issue is well explained here init_by_lua is no longer run in Nginx config test??

I need this feature as well and I consider it to be very important for guaranteeing stability during Nginx reloads.

Here are some suggestions to be considered.

  1. Making running init_by_lua during "nginx -t" conditional by a directive
  2. Adding a new phase like config_test_by_lua therefore seperating it from init_by_lua, so resolving the reason why this feature was removed in the first place.
spacewander commented 3 months ago

https://github.com/openresty/lua-nginx-module/pull/1377#issuecomment-420604831 Maybe you can use this way.

spacewander commented 3 months ago

The init_by_lua is disabled during nginx -t and nginx -s because complex OpenResty APP will have much logic in the init_by_lua.

Rockybilly commented 3 months ago

#1377 (comment) Maybe you can use this way.

Thank you, it is certainly a valid workaround, however harder for me to implement in my current setup (hundreds of servers). With the current openresty toolset, it's easier for me to track reload failures and manually check error.log. If possible in the future config_test_by_lua_block kind of extra phase would be very meaningful for the usage cases of openresty.