52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package monitor
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
websocket2 "ems.agt/lib/websocket"
|
|
"ems.agt/restagent/config"
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
var (
|
|
// 進程
|
|
UriWs = config.UriPrefix + "/monitor/{apiVersion}/process/ws"
|
|
)
|
|
|
|
var wsUpgrade = websocket.Upgrader{
|
|
CheckOrigin: func(r *http.Request) bool {
|
|
return true
|
|
},
|
|
}
|
|
|
|
func ProcessWs(w http.ResponseWriter, r *http.Request) {
|
|
ws, err := wsUpgrade.Upgrade(w, r, nil)
|
|
if err != nil {
|
|
return
|
|
}
|
|
wsClient := websocket2.NewWsClient("processClient", ws)
|
|
go wsClient.Read()
|
|
go wsClient.Write()
|
|
}
|
|
|
|
// @Tags Process
|
|
// @Summary Stop Process
|
|
// @Description 停止进程
|
|
// @Param request body request.ProcessReq true "request"
|
|
// @Success 200
|
|
// @Security ApiKeyAuth
|
|
// @Router /process/stop [post]
|
|
// @x-panel-log {"bodyKeys":["PID"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"结束进程 [PID]","formatEN":"结束进程 [PID]"}
|
|
func StopProcess(w http.ResponseWriter, r *http.Request) {
|
|
// var req request.ProcessReq
|
|
// if err := c.ShouldBindJSON(&req); err != nil {
|
|
// helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
// return
|
|
// }
|
|
// if err := processService.StopProcess(req); err != nil {
|
|
// helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
// return
|
|
// }
|
|
// helper.SuccessWithOutData(c)
|
|
}
|