问题
I'm writing lua script that is going to run inside HAproxy
using it's Lua API.
My script is using socket
package which I want to install on my machine.
Currently I'm running inside docker and my dockerfile looks like this:
FROM haproxy:1.7
RUN apt-get update -y && apt-get install curl luarocks -y
RUN luarocks install luasocket
EXPOSE 80 9000
COPY 500error.json.http /etc/haproxy/errorfiles/
COPY hello_world.lua /etc/haproxy/scripts/
my script have the next line:
local http = require('socket.http')
which works okay when running lua interpreter but not when running haproxy:
[ALERT] 298/104833 (8) : parsing [/usr/local/etc/haproxy/haproxy.cfg:5] : lua runtime error: /etc/haproxy/scripts/hello_world.lua:1: module 'socket.http' not found:
How should I load this correctly to haproxy?
回答1:
You can print package.path
and package.cpath
values just before require luasocket module.
This values is where lua store paths to load a library.
来源:https://stackoverflow.com/questions/47124011/how-to-load-3rd-party-lua-libs-installed-via-luarocks-into-haproxy