mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-06 20:15:48 +08:00
安装时默认设置访问日志保留30天
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/go-yaml/yaml"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -200,6 +201,26 @@ func (this *InstallAction) RunPost(params struct {
|
||||
this.Fail("设置管理员账号出错:" + err.Error())
|
||||
}
|
||||
|
||||
// 设置访问日志保留天数
|
||||
var accessLogKeepDays = dbMap.GetInt("accessLogKeepDays")
|
||||
if accessLogKeepDays > 0 {
|
||||
var config = &systemconfigs.DatabaseConfig{}
|
||||
config.ServerAccessLog.Clean.Days = accessLogKeepDays
|
||||
configJSON, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
this.Fail("配置设置访问日志保留天数出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
_, err = client.SysSettingRPC().UpdateSysSetting(ctx, &pb.UpdateSysSettingRequest{
|
||||
Code: systemconfigs.SettingCodeDatabaseConfigSetting,
|
||||
ValueJSON: configJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.Fail("配置设置访问日志保留天数出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err = apiConfig.WriteFile(Tea.ConfigFile("api.yaml"))
|
||||
if err != nil {
|
||||
this.Fail("保存配置失败,原因:" + err.Error())
|
||||
@@ -232,6 +253,26 @@ func (this *InstallAction) RunPost(params struct {
|
||||
this.Fail("设置管理员账号出错:" + err.Error())
|
||||
}
|
||||
|
||||
// 设置访问日志保留天数
|
||||
var accessLogKeepDays = dbMap.GetInt("accessLogKeepDays")
|
||||
if accessLogKeepDays > 0 {
|
||||
var config = &systemconfigs.DatabaseConfig{}
|
||||
config.ServerAccessLog.Clean.Days = accessLogKeepDays
|
||||
configJSON, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
this.Fail("配置设置访问日志保留天数出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
_, err = client.SysSettingRPC().UpdateSysSetting(ctx, &pb.UpdateSysSettingRequest{
|
||||
Code: systemconfigs.SettingCodeDatabaseConfigSetting,
|
||||
ValueJSON: configJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.Fail("配置设置访问日志保留天数出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 写入API节点配置,完成安装
|
||||
err = apiConfig.WriteFile(Tea.ConfigFile("api.yaml"))
|
||||
if err != nil {
|
||||
|
||||
@@ -15,11 +15,12 @@ type ValidateDbAction struct {
|
||||
}
|
||||
|
||||
func (this *ValidateDbAction) RunPost(params struct {
|
||||
Host string
|
||||
Port string
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
Host string
|
||||
Port string
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
AccessLogKeepDays int
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -98,12 +99,13 @@ func (this *ValidateDbAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
this.Data["db"] = maps.Map{
|
||||
"host": params.Host,
|
||||
"port": params.Port,
|
||||
"database": params.Database,
|
||||
"username": params.Username,
|
||||
"password": params.Password,
|
||||
"passwordMask": strings.Repeat("*", len(params.Password)),
|
||||
"host": params.Host,
|
||||
"port": params.Port,
|
||||
"database": params.Database,
|
||||
"username": params.Username,
|
||||
"password": params.Password,
|
||||
"passwordMask": strings.Repeat("*", len(params.Password)),
|
||||
"accessLogKeepDays": params.AccessLogKeepDays,
|
||||
}
|
||||
|
||||
this.Success()
|
||||
|
||||
Reference in New Issue
Block a user