Giter Site home page Giter Site logo

luarocks about lua-nginx-module HOT 14 CLOSED

openresty avatar openresty commented on September 23, 2024
luarocks

from lua-nginx-module.

Comments (14)

chaoslawful avatar chaoslawful commented on September 23, 2024

Hi,

I tried requiring and using several luarocks-installed modules in ngx_lua, including luasocket and luayaml, and found no errors. Could you show us some problematic modules and example scripts?

Thanks!

from lua-nginx-module.

jney avatar jney commented on September 23, 2024

Hi,

Depending on the rocks i am calling, i got this kind of error :

2011/02/12 11:10:03 [error] 42397#0: *72 content_by_lua aborted: runtime error: /usr/local/share/lua/5.1/luarocks/loader.lua:95: error loading module 'lpeg' from file '/usr/local/lib/luarocks/lib/lua/5.1//lpeg.so':
dlopen(/usr/local/lib/luarocks/lib/lua/5.1//lpeg.so, 2): Symbol not found: _luaL_addlstring
Referenced from: /usr/local/lib/luarocks/lib/lua/5.1//lpeg.so
Expected in: dynamic lookup
, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:6789"
2011/02/12 11:10:03 [error] 42397#0: *73 content_by_lua aborted: runtime error: /Users/jney/src/test/server.lua:2: loop or previous error loading module 'json', client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", host: "localhost:6789"

Or this kind :

2011/02/12 10:51:54 [error] 39866#0: *59 content_by_lua aborted: runtime error: /Users/jney/src/test/server.lua:2: module 'luasocket' not found:

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

Hi,

Rocks luasocket/lpeg/luajson work well with ngx_lua in my environment...Would you please offer the following commands' output?

  • uname -a

  • /path/to/your/nginx/executable -V

  • nm /path/to/your/nginx/executable | grep luaL_

  • ldd /path/to/your/nginx/executable

  • Output of this script in your nginx with ngx_lua:

    require("luarocks.require")
    ngx.say(package.path)
    ngx.say(package.cpath)

  • luarocks --version; luarocks path

from lua-nginx-module.

jney avatar jney commented on September 23, 2024

Hi,

Here it is :

  • uname -a :

    Darwin hackro 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 i386

  • nginx -V

    nginx version: nginx/0.8.54
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/Cellar/nginx/0.8.54 --with-http_ssl_module --with-pcre --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/nginx/nginx.lock --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_realip_module --with-http_gzip_static_module --with-http_geoip_module --add-module=/Users/jney/src/nginx/ngx_devel_kit/ --add-module=/Users/jney/src/nginx/lua-nginx-module/ --add-module=/Users/jney/src/nginx/redis2-nginx-module/ --add-module=/Users/jney/src/nginx/encrypted-session-nginx-module/

  • nm $(which nginx) | grep luaL_

    zsh: done nm $(which nginx) |
    zsh: exit 1 grep --color=auto luaL_

  • otool -L $(which nginx)

    /usr/local/sbin/nginx:
    /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
    /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libpcre.0.dylib (compatibility version 1.0.0, current version 1.1.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    /usr/local/Cellar/geoip/1.4.6/lib/libGeoIP.1.dylib (compatibility version 6.0.0, current version 6.6.0)

  • require("luarocks.require") ngx.say(package.path) ngx.say(package.cpath)

    package.path :
    /usr/local/lib/luarocks/share/lua/5.1//?.lua;/usr/local/lib/luarocks/share/lua/5.1//?/init.lua;/.luarocks/share/lua/5.1//?.lua;/.luarocks/share/lua/5.1//?/init.lua;./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua
    package.cpath :
    /usr/local/lib/luarocks/lib/lua/5.1//?.so;/.luarocks/lib/lua/5.1//?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so

  • luarocks --version

    luarocks 2.0.2
    LuaRocks main command-line interface

I don't know how to get luarocks path, but i think it is /usr/local/lib/luarocks
Plus, when i require a rocks in a script with lua installed binary, it works. so i tried to set lua_package_path and lua_package_cpath to what i got on my system, getting them with package.path and package.cpath. but it doesn't work.

Thank you for the support.

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

Hi,

It's weird that your nginx executable doesn't export any luaL_* symbols. What about the standard lua executable? Would you run the nm cmdline on it again and paste its output?

Besides, the strace output of nginx is also helpful. Please run:

strace -o strace.log /path/to/your/nginx/executable

Access the problematic script, then interrupt strace and send both strace.log and the script itself to me.

Thanks

from lua-nginx-module.

jney avatar jney commented on September 23, 2024

Here it is :

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

Sorry, I mean the output of nm $(which lua). Besides, would you add -f option to dtruss in order to trace all the child processes, like sudo dtruss -a -f -l $(which nginx) 2>&1 | tee ./trace.log > /dev/null ?

from lua-nginx-module.

jney avatar jney commented on September 23, 2024

Here it is :

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

It seems that nginx executable doesn't export lua related symbols, so lua c-modules doesn't work. On Linux there's -E linking options to do executable symbols exporting, I don't know if OSX has some linking options with similar behavior. Could you search your linker's document to find some hints?

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

You compiled nginx with homebrew interactive shell, right? I tried this way under OSX, and found that homebrew strangely disabled all exported symbols from installed nginx executable file. The exported symbols are correct both in the building directory AND installed directory, as long as we are in homebrew interactive shell. We have to find out what had it done after building shell exited.

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

OK...homebrew just stripped debug symbols out of nginx executables, normally this should be okay. But it seems that lpeg could not work in such a environment, we have to dig out reason from lpeg...

from lua-nginx-module.

chaoslawful avatar chaoslawful commented on September 23, 2024

Sorry, the problem is related to luarocks, not lpeg. We'll find out how to solve it....

from lua-nginx-module.

agentzh avatar agentzh commented on September 23, 2024

Sorry for the delay but I just tried and could not reproduce this issue on Mac OS X 10.6.8 using the standard nginx tarball and plain gcc (shipped by Xcode).

How exactly did you build your nginx/ngx_lua? Have you stripped dynamic symbols from your nginx executable?

Can you try out the ngx_openresty bundle to see if it works with your LuaRocks modules? http://openresty.org/#Download

from lua-nginx-module.

agentzh avatar agentzh commented on September 23, 2024

Consider it resolved.

from lua-nginx-module.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.