Hello!
On Fri, Jun 12, 2015 at 6:50 AM, Damian Myerscough wrote:
> is it possible to specify two files in init_by_lua_file? I have two files
> that need to be configured globally and specifying two init_by_lua_file
> causes Nginx to fail. I thought about creating a single lua file that just
> pulls in the two files but I wanted to see if there was any other methods
> of doing this.
>
No, you should not specify multiple init_by_lua_file directives in the
same context. This is simply not allowed. The same applies to most of
the other directives provided by ngx_lua, including content_by_lua and
rewrite_by_lua.
The recommended way is to use Lua module files to organize your Lua
code (and to use "require()" to load your own modules in your Lua
code). This is also much more efficient than the duplicate directive
way (if I were to implement, though not really likely). See
OpenResty's existing lua-resty-redis library for such an example in
the real world.
Regards,
-agentzh