如何将第三方lua libs(通过luarocks安装)加载到haproxy中

时间:2017-11-05 16:40:38

标签: lua haproxy

我正在使用它的Lua API编写将在HAproxy内运行的lua脚本。

我的脚本正在使用我想在我的计算机上安装的socket包。

目前我在docker中运行,我的dockerfile如下所示:

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/

我的脚本有下一行:

local http = require('socket.http')

在运行lua解释器时运行正常但在运行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:

我应该如何正确加载到haproxy?

1 个答案:

答案 0 :(得分:0)

您可以在需要luasocket模块之前打印package.pathpackage.cpath值。

此值是lua存储加载库的路径。