how to load 3rd party lua libs (installed via luarocks) into haproxy

情到浓时终转凉″ 提交于 2019-12-13 03:20:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!