lua_package_path "/data0/www/lua/?.lua;;";
server
{
listen 8001;
index index.html index.htm index.php;
root /data0/storage/down/;
lua_code_cache off;
location / {
#access_by_lua_file /data0/www/lua/test.lua;
log_by_lua_file /data0/www/lua/test1.lua;
#limit_rate 10k;
}
location /status {
default_type 'text/plain';
content_by_lua_file /data0/www/lua/test3.lua;
}
}
test1.lua
=============
local redis = require "redis"
local cache = redis.new()
local ok, err = cache.connect(cache, '127.0.0.1', '6379')
cache:set_timeout(60000)
if not ok then
ngx.say("failed to connect:", err)
return
end
res, err = cache:set("tag", ngx.var.body_bytes_sent)
if not ok then
ngx.say("failed to set tag: ", err)
return
end
local ok, err = cache:close()
if not ok then
ngx.say("failed to close:", err)
return
end
发现我下载url:8001/test.zip 之后 他这段没执行,不知道是怎么回事。