Awesome! I'll take a look into it this weekend. Thanks!
Em qua, 13 de mar de 2019 às 14:11, Shu Kit Chan <[email protected]> escreveu: > Hopefully this would be the answer to your problem - > https://github.com/apache/trafficserver/issues/5158 > > Thanks. > > Kit > > On Mon, Mar 11, 2019 at 9:54 AM Eric Chaves <[email protected]> wrote: > > > > Hi Shun, thanks for helping me out in this out-of-topic situation. I > spent the weekend reading about this error on the internet (starting with > the links you shared) trying to figure out what I could be doing wrong but > with my limited knowledge on lua I wasn't able to figure it out. > > > > The comments on luasocket issue's implies that this error could be due > to a misconfigured build whose symbols were not being linked/exported > properly, so I tried to check the symbol resolution for tslua.so using the > command line 'nm -gC libexec/trafficserver/tslua.so | grep lua_' using > different build configs (with only luajit installed/not lua, without > luajit, with luajit path explicitly set, etc). In all builds the results > were the same: every lua_* symbol is marked as Undefined (39 symbols in > total). > > > > I'm not sure if this means something since the tslua plugin does execute > lua properly, but this was as far as I got. > > > > I also tried to install luasocket from it's source code but it failed > because it didn't find some lua headers (ie lua.h, etc) which enforces that > I'm somehow breaking the build but I can't point my finger on anything. As > far as I can tell I'm following the steps present both at the docs and at > trafficserve's confluence. I've also based my self on some 3rd part > dockerfiles at github. > > > > If have some spare time could you please take a look on my Dockerfile ( > https://github.com/ericchaves/ats-lua-playground/blob/master/trafficserver.dockerfile) > so see if you spot any mistakes that I may be doing (maybe I'm missing some > required CC flag)? Or if you could share your build steps (even if it's not > dockerbased) so I can compare with mine. > > > > If you can't help me any further for any reason, that's ok either. You > have being of great support no matter what. =) > > > > Regards, > > > > Em sex, 8 de mar de 2019 às 13:15, Shu Kit Chan <[email protected]> > escreveu: > >> > >> 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 <[email protected]> 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 <[email protected]> > 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 <[email protected]> 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 > >> >> > >
