mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: 修改 docker 服务状态判断
This commit is contained in:
parent
a6140aa647
commit
e7bf661eca
@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -11,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,20 +38,20 @@ type daemonJsonItem struct {
|
|||||||
|
|
||||||
func (u *DockerService) LoadDockerStatus() string {
|
func (u *DockerService) LoadDockerStatus() string {
|
||||||
status := constant.StatusRunning
|
status := constant.StatusRunning
|
||||||
cli, err := docker.NewDockerClient()
|
cmd := exec.Command("systemctl", "is-active", "docker")
|
||||||
if err != nil {
|
stdout, err := cmd.CombinedOutput()
|
||||||
status = constant.Stopped
|
if string(stdout) != "active\n" || err != nil {
|
||||||
}
|
|
||||||
pong, err := cli.Ping(context.Background())
|
|
||||||
if !pong.Experimental || err != nil {
|
|
||||||
status = constant.Stopped
|
status = constant.Stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
|
func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
|
||||||
status := constant.StatusRunning
|
status := constant.StatusRunning
|
||||||
if _, err := docker.NewDockerClient(); err != nil {
|
cmd := exec.Command("systemctl", "is-active", "docker")
|
||||||
|
stdout, err := cmd.CombinedOutput()
|
||||||
|
if string(stdout) != "active\n" || err != nil {
|
||||||
status = constant.Stopped
|
status = constant.Stopped
|
||||||
}
|
}
|
||||||
fileSetting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath"))
|
fileSetting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath"))
|
||||||
|
@ -90,7 +90,7 @@ const form = reactive({
|
|||||||
from: 'edit',
|
from: 'edit',
|
||||||
path: '',
|
path: '',
|
||||||
file: '',
|
file: '',
|
||||||
template: 0,
|
template: null as number,
|
||||||
});
|
});
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
name: [Rules.requiredInput, Rules.name],
|
name: [Rules.requiredInput, Rules.name],
|
||||||
|
@ -176,6 +176,7 @@ const onOperator = async (operation: string) => {
|
|||||||
operation: operation,
|
operation: operation,
|
||||||
};
|
};
|
||||||
await dockerOperate(param);
|
await dockerOperate(param);
|
||||||
|
search();
|
||||||
changeMode();
|
changeMode();
|
||||||
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user