feat: 修改 Supervisor 的判断 (#1876)

This commit is contained in:
zhengkunwang 2023-08-08 17:00:12 +08:00 committed by GitHub
parent 0e8a4eaf2e
commit 381233a8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 16 deletions

View File

@ -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 != "" {

View File

@ -168,3 +168,8 @@ func SudoHandleCmd() string {
}
return ""
}
func Which(name string) bool {
_, err := exec.LookPath(name)
return err == nil
}

View File

@ -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)

View File

@ -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;

View File

@ -8,7 +8,7 @@
{{ $t('website.log') }}
</el-button>
<el-button type="primary" :plain="activeName !== '3'" @click="changeTab('3')">
{{ $t('website.basic') }}
{{ $t('commons.button.init') }}
</el-button>
</template>
<template #main>