mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-25 03:29:13 +08:00
fix: 应用停止使用 docker-compose stop
This commit is contained in:
parent
4307673f7b
commit
bd1c8b2fd8
@ -376,13 +376,17 @@ func syncById(installId uint) error {
|
||||
errorContainers []string
|
||||
notFoundContainers []string
|
||||
runningContainers []string
|
||||
exitedContainers []string
|
||||
)
|
||||
|
||||
for _, n := range containers {
|
||||
if n.State != "running" {
|
||||
errorContainers = append(errorContainers, n.Names[0])
|
||||
} else {
|
||||
switch n.State {
|
||||
case "exited":
|
||||
exitedContainers = append(exitedContainers, n.Names[0])
|
||||
case "running":
|
||||
runningContainers = append(runningContainers, n.Names[0])
|
||||
default:
|
||||
errorContainers = append(errorContainers, n.Names[0])
|
||||
}
|
||||
}
|
||||
for _, old := range containerNames {
|
||||
@ -401,6 +405,7 @@ func syncById(installId uint) error {
|
||||
containerCount := len(containers)
|
||||
errCount := len(errorContainers)
|
||||
notFoundCount := len(notFoundContainers)
|
||||
existedCount := len(exitedContainers)
|
||||
normalCount := len(containerNames)
|
||||
runningCount := len(runningContainers)
|
||||
|
||||
@ -409,16 +414,17 @@ func syncById(installId uint) error {
|
||||
appInstall.Message = "container is not found"
|
||||
return appInstallRepo.Save(&appInstall)
|
||||
}
|
||||
if errCount == 0 && notFoundCount == 0 {
|
||||
if errCount == 0 && existedCount == 0 {
|
||||
appInstall.Status = constant.Running
|
||||
return appInstallRepo.Save(&appInstall)
|
||||
}
|
||||
if existedCount == normalCount {
|
||||
appInstall.Status = constant.Stopped
|
||||
return appInstallRepo.Save(&appInstall)
|
||||
}
|
||||
if errCount == normalCount {
|
||||
appInstall.Status = constant.Error
|
||||
}
|
||||
if notFoundCount == normalCount {
|
||||
appInstall.Status = constant.Stopped
|
||||
}
|
||||
if runningCount < normalCount {
|
||||
appInstall.Status = constant.UnHealthy
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ func Up(filePath string) (string, error) {
|
||||
}
|
||||
|
||||
func Down(filePath string) (string, error) {
|
||||
cmd := exec.Command("docker-compose", "-f", filePath, "down")
|
||||
cmd := exec.Command("docker-compose", "-f", filePath, "stop")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
return string(stdout), err
|
||||
}
|
||||
|
@ -50,9 +50,7 @@
|
||||
trigger="hover"
|
||||
:content="row.message"
|
||||
>
|
||||
<template #reference>
|
||||
<el-tag type="error">{{ row.status }}</el-tag>
|
||||
</template>
|
||||
<template #reference>{{ row.status }}</template>
|
||||
</el-popover>
|
||||
|
||||
<el-tag v-else>
|
||||
|
Loading…
Reference in New Issue
Block a user