Add Nginx configuration check and reload logs when calling BunkerWeb /reload

This commit is contained in:
Théophile Diot 2024-03-07 18:24:10 +00:00
parent 86008e61f8
commit f0328db3d6
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -94,10 +94,12 @@ end
api.global.POST["^/reload$"] = function(self)
-- Check config
logger:log(NOTICE, "Checking Nginx configuration")
local status = execute("nginx -t")
if status ~= 0 then
return self:response(HTTP_INTERNAL_SERVER_ERROR, "error", "config check failed")
end
logger:log(NOTICE, "Nginx configuration is valid, reloading Nginx")
-- Send HUP signal to master process
local ok, err = kill(get_master_pid(), "HUP")
if not ok then