Adis,

Am 09.01.20 um 10:27 schrieb Adis Nezirovic:
> global
>   lua-load /path/to/config.lua
>   lua-load /path/to/app.lua
> […]
> And now for the main topic, if you need to set any paths for Lua
> scripts/libraries in non standard locations, you can directly use
> package.path in config.lua script
> 
>   package.path = package.path .. ';/some/path/?.lua'
> 
> 
> That way, there is no need for users to edit app script, and they can
> override configuration or Lua path settings. IMO, we don't need another
> directive in HAProxy just to set Lua paths.

Yes, I am aware that this would work. I dislike needing an additional
configuration file that would contain a single line more often than not.
Because then I need to context switch to understand the configuration.

It would also make it easier to explain for administrators to set-up. I
can just tell them:

"put haproxy-lua-http into /etc/haproxy/lua-modules and add that folder
to `lua-prepend-path` and lua-load haproxy-auth-request"
vs
"put haproxy-lua-http somewhere, then create another Lua script
containing package.path = package.path .. ';/that/folder/?.lua' and then
lua-load that one in addition to haproxy-auth-request".

However this morning I started thinking whether it might make sense to
generalize `lua-prepend-path` to `lua-run-string` that would execute the
Lua script given as the parameter. It might provide better flexibility
and would be as readable as lua-prepend-path:

lua-run-string "package.path = package.path .. ';/some/path/?.lua'"

Opinions?

Best regards
Tim Düsterhus

Reply via email to