Openresty nginx reload не работает? (Обновленные переменные равны нулю в файле lua)
В настоящее время я передаю некоторые новые переменные в мой файл lua, кажется, что эти новые переменные nil
когда я выхожу из системы и удаляю свою старую переменную saveFileRootPath
но старая переменная все еще может быть зарегистрирована.
Вот часть моего conf nginx:
location /fileupload {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,fileheader';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,fileheader';
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,fileheader';
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
}
default_type text/html;
set $fileSaveListingPath "C:\\Services\\openresty\\html_ecomm\\files\\listing";
set $fileSaveDetailPath "C:\\Services\\openresty\\html_ecomm\\files\\detail";
set $fileSaveZoomPath "C:\\Services\\openresty\\html_ecomm\\files\\zoom";
content_by_lua_file lua/fileupload.lua;
}
Добавлено 3 новые переменные fileSaveListingPath
, fileSaveDetailPath
& fileSaveZoomPath
которые зарегистрированы как nil
,
Убрал старую переменную fileSaveRootPath
но все еще может быть зарегистрировано.
Я чувствую, что, может быть, есть тайник? Кеш выключен, афаик.
Вот верхняя часть моего файла lua:
local http = require "resty.http"
local upload = require "resty.upload"
local cjson = require "cjson"
local saveRootPath = ngx.var.fileSaveRootPath
ngx.log(ngx.ERR, "TEST: "..ngx.var.fileSaveRootPath )
local chunk_size = 4096
local form, err = upload:new(chunk_size)
if not form then
ngx.log(ngx.ERR, "failed to new upload: ", err)
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end
form:set_timeout(1000)
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
Как вы можете видеть из кода, ngx.var.fileSaveRootPath
Я попытался войти, и это все еще может быть зарегистрировано по некоторым причинам. Кстати, это со стороны сервера, поэтому я не хочу просто перезагружать весь сервер.
PS:nginx -s reload
не работал для меня
Некоторые журналы ошибок:
2018/03/12 11:42:45 [info] 10660#10372: *4506 client closed connection while waiting for request, client: 124.13.241.136, server: 0.0.0.0:16001
2018/03/12 11:44:40 [error] 10660#10372: *4508 lua entry thread aborted: runtime error: ./lua/fileupload.lua:9: attempt to concatenate field 'fileSaveListingPath' (a nil value)
stack traceback:
coroutine 0:
./lua/fileupload.lua: in function <./lua/fileupload.lua:1>, client: 124.13.241.136, server: db.hkltd.com, request: "POST /fileupload/ HTTP/1.1", host: "xxx.com:16003", referrer: "http://localhost:3000/catalogmanagement/8868"
2018/03/12 11:45:43 [info] 10660#10372: *4514 client closed connection while waiting for request, client: 124.13.241.136, server: 0.0.0.0:16003
2018/03/12 11:58:16 [error] 10660#10372: *4516 lua entry thread aborted: runtime error: ./lua/fileupload.lua:9: attempt to concatenate field 'fileSaveListingPath' (a nil value)
stack traceback:
coroutine 0:
./lua/fileupload.lua: in function <./lua/fileupload.lua:1>, client: 124.13.241.136, server: xxx.com, request: "POST /fileupload/ HTTP/1.1", host: "xxx:16003", referrer: "xxx.com:16003/catalogmanagement/8868"
1 ответ
Нашел ответ здесь.
Эта часть: The immediate consequence is that you can't use custom variables in an http block.
Похоже, я пытался установить свои собственные переменные, но на самом деле вы не можете сделать это в nginx conf file afaik.
Мое решение состояло в том, чтобы просто установить мое местоположение в файле lua, и все было хорошо.
PS:
nginx -s reload
работает как надо. Я добавил пару записей сервера, и перезагрузка работала нормально.