mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
创建网站服务后自动开启访问日志
This commit is contained in:
@@ -71,6 +71,9 @@ func (this *CreateAction) RunPost(params struct {
|
||||
CertIdsJSON []byte
|
||||
Origins string
|
||||
|
||||
AccessLogIsOn bool
|
||||
WebsocketIsOn bool
|
||||
|
||||
WebRoot string
|
||||
|
||||
Must *actions.Must
|
||||
@@ -423,8 +426,36 @@ func (this *CreateAction) RunPost(params struct {
|
||||
// 开启访问日志和Websocket
|
||||
if params.ServerType == serverconfigs.ServerTypeHTTPProxy {
|
||||
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), serverId)
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
} else {
|
||||
// 访问日志
|
||||
if params.AccessLogIsOn {
|
||||
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
|
||||
WebId: webConfig.Id,
|
||||
AccessLogJSON: []byte(`{
|
||||
"isPrior": false,
|
||||
"isOn": true,
|
||||
"fields": [],
|
||||
"status1": true,
|
||||
"status2": true,
|
||||
"status3": true,
|
||||
"status4": true,
|
||||
"status5": true,
|
||||
|
||||
"storageOnly": false,
|
||||
"storagePolicies": [],
|
||||
|
||||
"firewallOnly": false
|
||||
}`),
|
||||
})
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// websocket
|
||||
if params.WebsocketIsOn {
|
||||
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.AdminContext(), &pb.CreateHTTPWebsocketRequest{
|
||||
HandshakeTimeoutJSON: []byte(`{
|
||||
"count": 30,
|
||||
@@ -453,6 +484,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建代理服务 %d", createResp.ServerId)
|
||||
|
||||
@@ -86,6 +86,15 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>默认开启配置</td>
|
||||
<td>
|
||||
<checkbox checked="checked" name="accessLogIsOn">访问日志</checkbox>
|
||||
|
||||
<checkbox checked="checked" name="websocketIsOn">Websocket</checkbox>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user