mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
package v2
|
|
|
|
import (
|
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
|
websocket2 "github.com/1Panel-dev/1Panel/agent/utils/websocket"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (b *BaseApi) ProcessWs(c *gin.Context) {
|
|
ws, err := wsUpgrade.Upgrade(c.Writer, c.Request, 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":[],"BeforeFunctions":[],"formatZH":"结束进程 [PID]","formatEN":"结束进程 [PID]"}
|
|
func (b *BaseApi) StopProcess(c *gin.Context) {
|
|
var req request.ProcessReq
|
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
return
|
|
}
|
|
if err := processService.StopProcess(req); err != nil {
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
return
|
|
}
|
|
helper.SuccessWithOutData(c)
|
|
}
|