add: log system

This commit is contained in:
XZB-1248
2022-10-07 20:55:35 +08:00
parent c8437aa7c0
commit 844a0bab92
39 changed files with 923 additions and 222 deletions

View File

@@ -46,11 +46,20 @@ func KillDeviceProcess(ctx *gin.Context) {
ok = common.AddEventOnce(func(p modules.Packet, _ *melody.Session) {
if p.Code != 0 {
ctx.AbortWithStatusJSON(http.StatusInternalServerError, modules.Packet{Code: 1, Msg: p.Msg})
common.Warn(ctx, `KILL_PROCESS`, `fail`, p.Msg, map[string]any{
`pid`: form.Pid,
})
} else {
ctx.JSON(http.StatusOK, modules.Packet{Code: 0})
common.Info(ctx, `KILL_PROCESS`, `success`, ``, map[string]any{
`pid`: form.Pid,
})
}
}, target, trigger, 5*time.Second)
if !ok {
ctx.AbortWithStatusJSON(http.StatusGatewayTimeout, modules.Packet{Code: 1, Msg: `${i18n|responseTimeout}`})
common.Warn(ctx, `KILL_PROCESS`, `fail`, `timeout`, map[string]any{
`pid`: form.Pid,
})
}
}