mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-16 18:54:43 +08:00
feat: 修改 Supervisor 的判断 (#1876)
This commit is contained in:
parent
0e8a4eaf2e
commit
381233a8a5
@ -43,11 +43,17 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host
|
|||||||
res.Type = req.Type
|
res.Type = req.Type
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case constant.Supervisord:
|
case constant.Supervisord:
|
||||||
exist, _ := systemctl.IsExist(constant.Supervisord)
|
|
||||||
supervisorConfig := &response.Supervisor{}
|
supervisorConfig := &response.Supervisor{}
|
||||||
if !exist {
|
if !cmd.Which(constant.Supervisord) {
|
||||||
exist, _ = systemctl.IsExist(constant.Supervisor)
|
supervisorConfig.IsExist = false
|
||||||
if !exist {
|
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
|
supervisorConfig.IsExist = false
|
||||||
res.Config = supervisorConfig
|
res.Config = supervisorConfig
|
||||||
return res, nil
|
return res, nil
|
||||||
@ -57,7 +63,6 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host
|
|||||||
} else {
|
} else {
|
||||||
supervisorConfig.ServiceName = constant.Supervisord
|
supervisorConfig.ServiceName = constant.Supervisord
|
||||||
}
|
}
|
||||||
supervisorConfig.IsExist = true
|
|
||||||
|
|
||||||
serviceNameSet, _ := settingRepo.Get(settingRepo.WithByKey(constant.SupervisorServiceName))
|
serviceNameSet, _ := settingRepo.Get(settingRepo.WithByKey(constant.SupervisorServiceName))
|
||||||
if serviceNameSet.ID != 0 || serviceNameSet.Value != "" {
|
if serviceNameSet.ID != 0 || serviceNameSet.Value != "" {
|
||||||
|
@ -168,3 +168,8 @@ func SudoHandleCmd() string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Which(name string) bool {
|
||||||
|
_, err := exec.LookPath(name)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
@ -46,15 +46,6 @@ func Restart(serviceName string) error {
|
|||||||
out, err := RunSystemCtl("restart", serviceName)
|
out, err := RunSystemCtl("restart", serviceName)
|
||||||
return handlerErr(out, err)
|
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 {
|
func Operate(operate, serviceName string) error {
|
||||||
out, err := RunSystemCtl(operate, serviceName)
|
out, err := RunSystemCtl(operate, serviceName)
|
||||||
|
@ -65,7 +65,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
serviceName: data.value.serviceName,
|
serviceName: data.value.serviceName,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{ $t('website.log') }}
|
{{ $t('website.log') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" :plain="activeName !== '3'" @click="changeTab('3')">
|
<el-button type="primary" :plain="activeName !== '3'" @click="changeTab('3')">
|
||||||
{{ $t('website.basic') }}
|
{{ $t('commons.button.init') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user