Re: [openresty-en] Re: Lua/Nginx - MySQL

41 views
Skip to first unread message
Message has been deleted
Message has been deleted

Robert Paprocki

unread,
Aug 25, 2016, 6:58:39 PM8/25/16
to openre...@googlegroups.com
Can you post a full, minimal, reproducible example of the issue? And can you clarify exactly why the issue is? "It hangs" is not terrible descriptive. Is there an entry in the error log? Have you confirmed that your MySQL server is accessible via the host/port/name/password you provide?

On Thu, Aug 25, 2016 at 3:37 PM, Fr3DBr <fr3...@gmail.com> wrote:
For instance this is how it looks like:

Lua File:

local _M = {}

function _M.check_sql()

        local mysql = require "resty.mysql"
        local db, err = mysql:new()
        ...

end

function _M.init_timers()

        if ( ngx.worker.id() ~= nil ) then
                local ok, err = ngx.timer.at(10, _M.check_sql)
        end

end

return _M

Nginx Config:

 init_worker_by_lua '
     whmcs = require "lua/ext_sql"
     whmcs.init_timers()
 ';


Em quinta-feira, 25 de agosto de 2016 18:57:16 UTC-3, Fr3DBr escreveu:
Hi, guys.

I have a .lua file, which I an including towards my nginx.conf file. Although, when I try to use mysql from it, it hangs exactly here:

local mysql = require "resty.mysql"

I'm using openresty (latest version) and mysql is surely included there, but I'm not sure why using the resty.mysql extension inside a regular .lua file isn't working (even tho it is included through nginx config file).

Any light ? :D

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

Robert Paprocki

unread,
Aug 25, 2016, 7:06:02 PM8/25/16
to openresty-en
Hi,

On Thu, Aug 25, 2016 at 4:02 PM, Fr3DBr <fr3...@gmail.com> wrote:
Hi,

When I said it hangs, I mean it hangs because I've added logging output to a simple txt file before each line of code, and it hangs as soon this line is going to be parsed:
local mysql = require "resty.mysql"

It doesn't moves further, since it hangs there. Get it now ?

Perhaps try checking your tcp connectivity with tcpdump to ensure you can connect to your MySQL server from the box on which you're running your ngx + lua? Also, try enable debug logging in Nginx (make sure Nginx is compiled with --with-debug); lua tcpsock calls are debugged pretty thoroughly at the debug level, so can watch how Nginx is string to communicate to the remote TCP server.

 
So I wanted to know what could be missing to it work, or if I'm allowed to do this or not at all (in an external lua file, loaded by nginx.conf via require).

Yes, you can do it via external module. Sounds like you need to troubleshoot your TCP connectivity (see above).

Message has been deleted
Message has been deleted

Fr3DBr

unread,
Aug 25, 2016, 7:32:17 PM8/25/16
to openresty-en, rob...@cryptobells.com
Fixed, it was only an installation issue in my end, sorry. :)
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages