ne service action

This commit is contained in:
2023-10-08 11:58:22 +08:00
parent 3b789f65aa
commit c209873f6c
2 changed files with 26 additions and 6 deletions

View File

@@ -790,12 +790,30 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
return
}
case "ims":
actionCmd := fmt.Sprintf("sudo ims-%s", action)
cmd := exec.Command("ssh", sshHost, actionCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
if err != nil {
log.Error("Faile to execute ssh sudo ims-%s command:", action, err)
switch action {
case "start", "stop":
actionCmd := fmt.Sprintf("sudo ims-%s", action)
cmd := exec.Command("ssh", sshHost, actionCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
if err != nil {
log.Error("Faile to execute ssh sudo ims-%s command:", action, err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
case "restart":
actionCmd := "sudo ims-stop && sudo ims-start"
cmd := exec.Command("ssh", sshHost, actionCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
if err != nil {
log.Error("Faile to execute ssh sudo ims-%s command:", action, err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
default:
err = global.ErrCMUnknownServiceAction
log.Error("%v, action:%s", err, action)
services.ResponseInternalServerError500ProcessError(w, err)
return
}