新增定时任务封装以及配置自动清理数据库功能

新增
- server/config/timer.go
- server/initialize/timer.go
- server/utils/db_automation.go
- server/utils/timer/timed_task.go
修改
- server/config.yaml
- server/config/config/go
- server/global/global.go
- server/main.go
This commit is contained in:
songzhibin97
2021-04-17 14:50:44 +08:00
parent eb1911232b
commit 2b0a565120
9 changed files with 197 additions and 2 deletions
+14 -1
View File
@@ -114,4 +114,17 @@ tencent-cos:
# excel configuration
excel:
dir: './resource/excel/'
dir: './resource/excel/'
# timer task db clear table
Timer:
spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron?utm_source=godoc
detail: [
# tableName: 需要清理的表名
# compareField: 需要比较时间的字段
# interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数
# 2160h = 24 * 30 * 3 -> 三个月
{ tableName: "log" , compareField: "created_at", interval: "2160h" },
{ tableName: "log2" , compareField: "created_at", interval: "2160h" }
]