Welcome! Log In Create A New Profile

Advanced

Re: Does Eval Module work Now?

agentzh
January 11, 2011 02:26AM
On Tue, Jan 11, 2011 at 4:31 AM, Sirsiwal, Umesh <usirsiwal@verivue.com> wrote:
> Thanks agentzh,
> I tried rewrite_by_lua with the following simple Lua configuration:
>
> local res = ngx.location.capture("/memc?key=" .. memc_key )
> print("copass: res " .. res.status .. ' body ' .. res.body)
>
> if res.status == 404 then
>        print("copas: capture /memc_set")
>        res = ngx.location.capture("/memc_set?key=" .. memc_key)
>        print("copss: status " .. res.status);
> end
>

I've just tested this config snippet in my slackware linux x86_64 box
(nginx 0.8.54/0.9.3 + ngx_lua git HEAD) and it works fine. Here's the
config that I'm using:

location /memc {
set $memc_cmd get;
set $memc_key $arg_key;
memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
}

location /memc_set {
#set $memc_cmd set;
#set $memc_key $arg_key;
#memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
echo OK;
}

location /lua {
rewrite_by_lua '
local memc_key = "hello"
local res = ngx.location.capture("/memc?key=" .. memc_key )
print("copass: res " .. res.status .. " body " .. res.body)

if res.status == 404 then
print("copas: capture /memc_set")
res = ngx.location.capture("/memc_set?key=" .. memc_key)
print("copss: status " .. res.status);
end
';
content_by_lua 'return';
}

And here's the debugging outputs in my error.log:

2011/01/11 15:18:32 [info] 10985#0: *1 key: "hello" was not found by
memcached while reading response header from upstream, client:
127.0.0.1, server: localhost, request: "GET /lua HTTP/1.1",
subrequest: "/memc", upstream: "memcached://127.0.0.1:11211", host:
"localhost"
2011/01/11 15:18:32 [debug] 10985#0: *1 http wake parent request: "/lua?"
2011/01/11 15:18:32 [debug] 10985#0: *1 http posted request: "/lua?"
2011/01/11 15:18:32 [notice] 10985#0: *1 lua print: copass: res 404 body <html>
while sending to client, client: 127.0.0.1, server: localhost,
request: "GET /lua HTTP/1.1", host: "localhost"
2011/01/11 15:18:32 [notice] 10985#0: *1 lua print: copas: capture
/memc_set while sending to client, client: 127.0.0.1, server:
localhost, request: "GET /lua HTTP/1.1", host: "localhost"
2011/01/11 15:18:32 [debug] 10985#0: *1 http wake parent request: "/lua?"
2011/01/11 15:18:32 [debug] 10985#0: *1 http posted request: "/lua?"
2011/01/11 15:18:32 [notice] 10985#0: *1 lua print: copss: status 200,
client: 127.0.0.1, server: localhost, request: "GET /lua HTTP/1.1",
host: "localhost"

>
>
> I see that the subrequest was correctly issued to the /memc location. However /memc_set location subrequest was never issued.
>

Can you try out my testing config given above on your side? And paste
your complete nginx.conf and tell me which verison of nginx and
ngx_lua and what kind of operating system are you using?

Cheers,
-agentzh

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Does Eval Module work Now?

Sirsiwal, Umesh 2638 December 30, 2010 03:56PM

Re: Does Eval Module work Now?

agentzh 797 December 30, 2010 10:16PM

RE: Does Eval Module work Now?

Sirsiwal, Umesh 849 December 31, 2010 10:44AM

RE: Does Eval Module work Now?

Sirsiwal, Umesh 860 January 01, 2011 11:12PM

Re: Does Eval Module work Now?

agentzh 959 January 03, 2011 10:26PM

Re: Does Eval Module work Now?

agentzh 782 January 01, 2011 11:34PM

Re: Does Eval Module work Now?

agentzh 932 January 05, 2011 11:54PM

RE: Does Eval Module work Now?

Sirsiwal, Umesh 815 January 10, 2011 03:32PM

Re: Does Eval Module work Now?

agentzh 870 January 11, 2011 02:26AM

Re: Does Eval Module work Now?

agentzh 885 January 12, 2011 12:06AM

RE: Does Eval Module work Now?

Sirsiwal, Umesh 1203 January 12, 2011 09:30AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 223
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready