mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-21 16:50:25 +08:00
安装时默认设置访问日志保留30天
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
"github.com/go-yaml/yaml"
|
"github.com/go-yaml/yaml"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
@@ -200,6 +201,26 @@ func (this *InstallAction) RunPost(params struct {
|
|||||||
this.Fail("设置管理员账号出错:" + err.Error())
|
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"))
|
err = apiConfig.WriteFile(Tea.ConfigFile("api.yaml"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Fail("保存配置失败,原因:" + err.Error())
|
this.Fail("保存配置失败,原因:" + err.Error())
|
||||||
@@ -232,6 +253,26 @@ func (this *InstallAction) RunPost(params struct {
|
|||||||
this.Fail("设置管理员账号出错:" + err.Error())
|
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节点配置,完成安装
|
// 写入API节点配置,完成安装
|
||||||
err = apiConfig.WriteFile(Tea.ConfigFile("api.yaml"))
|
err = apiConfig.WriteFile(Tea.ConfigFile("api.yaml"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ func (this *ValidateDbAction) RunPost(params struct {
|
|||||||
Database string
|
Database string
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
AccessLogKeepDays int
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -104,6 +105,7 @@ func (this *ValidateDbAction) RunPost(params struct {
|
|||||||
"username": params.Username,
|
"username": params.Username,
|
||||||
"password": params.Password,
|
"password": params.Password,
|
||||||
"passwordMask": strings.Repeat("*", len(params.Password)),
|
"passwordMask": strings.Repeat("*", len(params.Password)),
|
||||||
|
"accessLogKeepDays": params.AccessLogKeepDays,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -188,6 +188,13 @@
|
|||||||
<p class="comment">连接数据库所需密码,没有密码的话就不需要填写。</p>
|
<p class="comment">连接数据库所需密码,没有密码的话就不需要填写。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>访问日志保留天数</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" name="accessLogKeepDays" style="width: 5em" maxlength="4" value="30"/>
|
||||||
|
<p class="comment">网站等服务记录的访问日志保留天数,防止无限制地占用数据库空间。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<button class="ui button" type="button" @click.prevent="goBackAPI"><i class="icon long arrow left"></i>上一步</button>
|
<button class="ui button" type="button" @click.prevent="goBackAPI"><i class="icon long arrow left"></i>上一步</button>
|
||||||
@@ -325,6 +332,12 @@
|
|||||||
<span v-else class="disabled">未填入密码</span>
|
<span v-else class="disabled">未填入密码</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>访问日志保留天数</td>
|
||||||
|
<td>
|
||||||
|
{{dbInfo.accessLogKeepDays}}天
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h3>管理员信息</h3>
|
<h3>管理员信息</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user