diff --git a/src/modules/nms_cxy/controller/system.go b/src/modules/nms_cxy/controller/system.go index 0ce57bb..54b583a 100644 --- a/src/modules/nms_cxy/controller/system.go +++ b/src/modules/nms_cxy/controller/system.go @@ -2,7 +2,6 @@ package controller import ( "fmt" - "nms_cxy/src/framework/config" "nms_cxy/src/framework/i18n" "nms_cxy/src/framework/utils/cmd" "nms_cxy/src/framework/utils/ctx" @@ -12,8 +11,7 @@ import ( neService "nms_cxy/src/modules/network_element/service" "nms_cxy/src/modules/nms_cxy/service" "nms_cxy/src/modules/nms_cxy/utils/common" - - "time" + "strings" "github.com/gin-gonic/gin" ) @@ -244,8 +242,12 @@ func (s *SystemController) RebootApp(c *gin.Context) { return } + cmdStr := fmt.Sprintf("sleep 2s && sudo service %s restart", strings.ToLower(neInfo.NeType)) + if neInfo.NeType == "IMS" { + cmdStr = "sleep 2s && sudo ims-start restart" + } go func() { - _, err := cmd.ExecWithCheck("nohup", "sh", "-c", "sleep 2s && service omc restart", "> /dev/null 2>&1 &\n") + _, err := cmd.ExecWithCheck("nohup", "sh", "-c", cmdStr, "> /dev/null 2>&1 &\n") if err != nil { fmt.Printf("NE service reboot error %s \n", err.Error()) } @@ -279,9 +281,16 @@ func (s *SystemController) RebootState(c *gin.Context) { return } - // 获取程序运行时间 - runTime := time.Since(config.RunTime()).Abs().Seconds() - if runTime > 120 { + cmdStr := fmt.Sprintf(`systemctl status %s | grep -oP 'Active: \K[^ ]+'`, strings.ToLower(neInfo.NeType)) + if neInfo.NeType == "IMS" { + cmdStr = `ims-status | grep -oP 'state: \K[^ ]+'` + } + output, err := cmd.ExecWithCheck("sudo", cmdStr) + if err != nil { + fmt.Printf("NE service reboot error %s \n", err.Error()) + } + + if strings.Contains(output, "inactive") { c.JSON(200, map[string]any{ "requestId": body.RequestId, "status": "fail",