qihaiyan commented on code in PR #7749:
URL: https://github.com/apache/apisix/pull/7749#discussion_r954556563
##########
apisix/plugins/log-rotate.lua:
##########
@@ -219,18 +209,67 @@ local function init_default_logs(logs_info, log_type)
end
+local function file_size(file)
+ local attr = lfs.attributes(file)
+ if attr then
+ return attr.size
+ end
+ return 0
+end
+
+
+local function rotate_file(files, now_time, max_kept)
+ 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()
+ local sig_user1 = signal.signum("USR1")
+
+ core.log.warn("send USR1 signal to master process [", pid, "] for
reopening log file")
+
+ if (pid and sig_user1) then
Review Comment:
Same as signal.signum, get_master_pid's return value maybe null. If we use
the return value directly, a warn is reported with Lua plugin in vscode.
If this is a nonsense warning message, i'll revert this change.
--
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]