diff --git a/backend/app/service/host_tool.go b/backend/app/service/host_tool.go index 2dca140c2..5955231f4 100644 --- a/backend/app/service/host_tool.go +++ b/backend/app/service/host_tool.go @@ -43,11 +43,17 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host res.Type = req.Type switch req.Type { case constant.Supervisord: - exist, _ := systemctl.IsExist(constant.Supervisord) supervisorConfig := &response.Supervisor{} - if !exist { - exist, _ = systemctl.IsExist(constant.Supervisor) - if !exist { + if !cmd.Which(constant.Supervisord) { + supervisorConfig.IsExist = false + res.Config = supervisorConfig + return res, nil + } + supervisorConfig.IsExist = true + serviceExist, _ := systemctl.IsExist(constant.Supervisord) + if !serviceExist { + serviceExist, _ = systemctl.IsExist(constant.Supervisor) + if !serviceExist { supervisorConfig.IsExist = false res.Config = supervisorConfig return res, nil @@ -57,7 +63,6 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host } else { supervisorConfig.ServiceName = constant.Supervisord } - supervisorConfig.IsExist = true serviceNameSet, _ := settingRepo.Get(settingRepo.WithByKey(constant.SupervisorServiceName)) if serviceNameSet.ID != 0 || serviceNameSet.Value != "" { diff --git a/backend/utils/cmd/cmd.go b/backend/utils/cmd/cmd.go index ff65a8e50..74804d269 100644 --- a/backend/utils/cmd/cmd.go +++ b/backend/utils/cmd/cmd.go @@ -168,3 +168,8 @@ func SudoHandleCmd() string { } return "" } + +func Which(name string) bool { + _, err := exec.LookPath(name) + return err == nil +} diff --git a/backend/utils/systemctl/systemctl.go b/backend/utils/systemctl/systemctl.go index 27ff4be6d..402fbf7a0 100644 --- a/backend/utils/systemctl/systemctl.go +++ b/backend/utils/systemctl/systemctl.go @@ -46,15 +46,6 @@ func Restart(serviceName string) error { out, err := RunSystemCtl("restart", serviceName) return handlerErr(out, err) } -func Start(serviceName string) error { - out, err := RunSystemCtl("start", serviceName) - return handlerErr(out, err) -} - -func Stop(serviceName string) error { - out, err := RunSystemCtl("stop", serviceName) - return handlerErr(out, err) -} func Operate(operate, serviceName string) error { out, err := RunSystemCtl(operate, serviceName) diff --git a/frontend/src/views/host/tool/supervisor/config/basic/index.vue b/frontend/src/views/host/tool/supervisor/config/basic/index.vue index 54fb5c1da..53e01cdf5 100644 --- a/frontend/src/views/host/tool/supervisor/config/basic/index.vue +++ b/frontend/src/views/host/tool/supervisor/config/basic/index.vue @@ -65,7 +65,7 @@ const submit = async (formEl: FormInstance | undefined) => { serviceName: data.value.serviceName, }) .then(() => { - MsgSuccess(i18n.global.t('commons.msg.createSuccess')); + MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); }) .finally(() => { loading.value = false; diff --git a/frontend/src/views/host/tool/supervisor/config/index.vue b/frontend/src/views/host/tool/supervisor/config/index.vue index 64900c935..116d95c4b 100644 --- a/frontend/src/views/host/tool/supervisor/config/index.vue +++ b/frontend/src/views/host/tool/supervisor/config/index.vue @@ -8,7 +8,7 @@ {{ $t('website.log') }} - {{ $t('website.basic') }} + {{ $t('commons.button.init') }}