spacewander commented on code in PR #7869:
URL: https://github.com/apache/apisix/pull/7869#discussion_r965519961
##########
apisix/plugins/log-rotate.lua:
##########
@@ -218,25 +221,42 @@ local function file_size(file)
end
-local function rotate_file(files, now_time, max_kept)
+local function rotate_file(files, now_time, max_kept, wait_time)
+ if isempty(files) then
+ return
+ end
+
+ local new_files = new_tab(2, 0)
+ -- rename the log files
for _, file in ipairs(files) do
local now_date = os_date("%Y-%m-%d_%H-%M-%S", now_time)
local new_file = rename_file(default_logs[file], now_date)
if not new_file then
return
end
- local pid = process.get_master_pid()
- core.log.warn("send USR1 signal to master process [", pid, "] for
reopening log file")
- local ok, err = signal.kill(pid, signal.signum("USR1"))
- if not ok then
- core.log.error("failed to send USR1 signal for reopening log file:
", err)
- end
+ tab_insert(new_files, new_file)
+ end
+
+ -- send signal to reopen log files
+ local pid = process.get_master_pid()
+ core.log.warn("send USR1 signal to master process [", pid, "] for
reopening log file")
+ local ok, err = signal.kill(pid, signal.signum("USR1"))
+ if not ok then
+ core.log.error("failed to send USR1 signal for reopening log file: ",
err)
+ end
+
+ if enable_compression then
+ -- Waiting for nginx reopen files
+ -- to avoid losing logs during compression
+ ngx_sleep(wait_time)
Review Comment:
@monkeyDluffy6017
Currently, there is no limitation for the user-specific wait_time. BTW, we
need to doc it if this argument is exposed to the user.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]