如何将第3方lua库(通过luarocks安装)加载到haproxy中 [英] how to load 3rd party lua libs (installed via luarocks) into haproxy
问题描述
我正在编写将使用Lua API在HAproxy
内部运行的lua脚本.
I'm writing lua script that is going to run inside HAproxy
using it's Lua API.
我的脚本使用的是socket
软件包,我想将其安装在计算机上.
My script is using socket
package which I want to install on my machine.
当前我正在docker内部运行,我的dockerfile如下所示:
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/
我的脚本下一行:
local http = require('socket.http')
在运行lua解释器时可以正常运行,但在运行haproxy时则不能运行:
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:
我应该如何正确地将其加载到haproxy?
How should I load this correctly to haproxy?
推荐答案
您可以在需要luasocket模块之前打印package.path
和package.cpath
值.
You can print package.path
and package.cpath
values just before require luasocket module.
此值是lua存储加载库的路径的地方.
This values is where lua store paths to load a library.
这篇关于如何将第3方lua库(通过luarocks安装)加载到haproxy中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!