trafficserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shu Kit Chan <chanshu...@gmail.com>
Subject Re: ts_lua error after using ts.add_package_path
Date Fri, 08 Mar 2019 16:15:34 GMT
I am not sure what's wrong with your setup.  i have used luasocket
before with no problem. perhaps this will shed some light ?

https://github.com/diegonehab/luasocket/issues/158
https://github.com/diegonehab/luasocket/issues/87

Thanks.

Kit

On Thu, Mar 7, 2019 at 6:59 AM Eric Chaves <eric@uolet.com> wrote:
>
> Nice!, It solved this error but  now I got the error "ERROR: [ts_lua] lua_pcall failed:
error loading module 'socket.core' from file '/opt/ats/lua_modules/lib/lua/5.1/socket/core.so':
/opt/ats/lua_modules/lib/lua/5.1/socket/core.so: undefined symbol: lua_gettop.
>
> Everything was built using lua 5.1. Any clues why I could be getting the undefined symbol?
Could I be missing some dependency?
>
> Em qua, 6 de mar de 2019 às 18:37, Shu Kit Chan <chanshukit@gmail.com> escreveu:
>>
>> Try not to call "add_package_path" / "add_package_cpath" inside the
>> lua module .
>> Call them in the same lua file containing the do_remap() function and
>> see if your problem is solved.
>>
>> Kit
>>
>> On Wed, Mar 6, 2019 at 1:23 PM Eric Chaves <eric@uolet.com> wrote:
>> >
>> > Hi folks,
>> >
>> > This may be a little off-topic. Not sure if questions regarding lua plugins/lua
scripts should be asked here in the list. If so forgive me and please point me the proper
place to ask.
>> >
>> > I'm trying to learn TS lua script's. At first I just followed the sample code
for reverse host header presented in the lua_plugin docs by writing a module named my_module.lua
required inside a do_remap() with the following content:
>> >
>> > local my_module = {}
>> > function my_module.send_response()
>> >   ts.debug('executing my_module.send_response')
>> >   ts.client_response.header['Rhost'] = ts.ctx['rhost']
>> >   return 0
>> > end
>> > return my_module
>> >
>> > This works fine and after that I tried to add some code to connect into a local
redis instance using libs installed by luarocks (eg.: luarocks install --tree /opt/ats/lua_modules
luasocket)
>> >
>> >  I found some scripts at github that uses the ts.add_package_path to include
the new modules and based on them I added those two lines at the top of my_module.lua:
>> >
>> > ts.add_package_path('/opt/ats/lua_modules/share/lua/5.1/?.lua;/opt/ats/lua_modules/share/lua/5.1/?/init.lua')
>> > ts.add_package_cpath('/opt/ats/lua_modules/share/lua/5.1/?.so')
>> >
>> > By doing so, even without actually requiring any new module (ie no other changes
in my_module logic) when my do_remap tries require my_module, I got an error: ERROR: [ts_lua]
lua_pcall failed: /opt/ats/lua-plugins/my_module.lua:6: can't get the instance conf
>> >
>> > So it's clear that I'm breaking something using the ts.add_package_path. I've
also tried to mangle with package.path variable with the same outcome.
>> >
>> > What am I doing wrong and how should I do to add those new packages?
>> >
>> > Cheers,
>> >
>> > Eric
>> >

Mime
View raw message