mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 07:22:49 +08:00
feat(timer): ClearLog 清理天数改为从配置读取,支持 env 覆盖
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -21,6 +21,10 @@ FIELDS_CACHE=false
|
|||||||
[LOG]
|
[LOG]
|
||||||
CHANNEL=file
|
CHANNEL=file
|
||||||
|
|
||||||
|
[TIMER]
|
||||||
|
# 清理日志保留天数(debug_log 表)
|
||||||
|
CLEAR_LOG_DAYS=3
|
||||||
|
|
||||||
[LANG]
|
[LANG]
|
||||||
default_lang=zh-cn
|
default_lang=zh-cn
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
// 配置参考:https://doc.ulthon.com/read/augushong/ulthon_admin/timer-mode/zh-cn/2.x.html
|
// 配置参考:https://doc.ulthon.com/read/augushong/ulthon_admin/timer-mode/zh-cn/2.x.html
|
||||||
$config = [
|
$config = [
|
||||||
'mode' => 'normal',
|
'mode' => 'normal',
|
||||||
@@ -9,6 +11,9 @@ $config = [
|
|||||||
'keepalive_timeout' => 86400, // 连接多长时间不通讯就关闭
|
'keepalive_timeout' => 86400, // 连接多长时间不通讯就关闭
|
||||||
'connect_timeout' => 86400, // 连接超时时间
|
'connect_timeout' => 86400, // 连接超时时间
|
||||||
'timeout' => 86400, // 请求发出后等待响应的超时时间
|
'timeout' => 86400, // 请求发出后等待响应的超时时间
|
||||||
|
|
||||||
|
// 清理日志保留天数(debug_log 表)
|
||||||
|
'clear_log_days' => Env::get('timer.clear_log_days', 3),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ class ClearLogBase extends TimerController
|
|||||||
|
|
||||||
public function do()
|
public function do()
|
||||||
{
|
{
|
||||||
Log::debug('清除3天的日志');
|
$days = (int) config('timer.clear_log_days', 3);
|
||||||
Db::name('debug_log')->where('create_time', '<', time() - 60 * 60 * 24 * 3)->delete();
|
Log::debug('清除' . $days . '天的日志');
|
||||||
|
Db::name('debug_log')->where('create_time', '<', time() - 60 * 60 * 24 * $days)->delete();
|
||||||
|
|
||||||
return 'success';
|
return 'success';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user