1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-19 05:39:26 +08:00

feat(appstore): Handle container restarting status for App (#7676)

This commit is contained in:
zhengkunwang 2025-01-09 17:02:22 +08:00 committed by GitHub
parent 022580bbb2
commit 2185c3d2e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 18 additions and 0 deletions

View File

@ -518,6 +518,9 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
if taskErr := installTask.Execute(); taskErr != nil { if taskErr := installTask.Execute(); taskErr != nil {
appInstall.Status = constant.InstallErr appInstall.Status = constant.InstallErr
appInstall.Message = taskErr.Error() appInstall.Message = taskErr.Error()
if strings.Contains(taskErr.Error(), "Timeout") && strings.Contains(taskErr.Error(), "Pulling") {
appInstall.Message = buserr.New("PullImageTimeout").Error() + appInstall.Message
}
_ = appInstallRepo.Save(context.Background(), appInstall) _ = appInstallRepo.Save(context.Background(), appInstall)
} }
}() }()

View File

@ -1338,6 +1338,7 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
exitedCount := 0 exitedCount := 0
pausedCount := 0 pausedCount := 0
runningCount := 0 runningCount := 0
restartingCount := 0
total := len(containerNames) total := len(containerNames)
for _, name := range containerNames { for _, name := range containerNames {
if con, ok := containers["/"+name]; ok { if con, ok := containers["/"+name]; ok {
@ -1347,6 +1348,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
exitNames = append(exitNames, name) exitNames = append(exitNames, name)
case "running": case "running":
runningCount++ runningCount++
case "restarting":
restartingCount++
case "paused": case "paused":
pausedCount++ pausedCount++
} }
@ -1362,6 +1365,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
if oldStatus == constant.Running { if oldStatus == constant.Running {
return return
} }
case restartingCount == total:
appInstall.Status = constant.Restating
case pausedCount == total: case pausedCount == total:
appInstall.Status = constant.Paused appInstall.Status = constant.Paused
case len(notFoundNames) == total: case len(notFoundNames) == total:

View File

@ -16,6 +16,7 @@ const (
UpErr = "UpErr" UpErr = "UpErr"
InstallErr = "InstallErr" InstallErr = "InstallErr"
Uninstalling = "Uninstalling" Uninstalling = "Uninstalling"
Restating = "Restarting"
ContainerPrefix = "1Panel-" ContainerPrefix = "1Panel-"

View File

@ -74,6 +74,7 @@ DeleteRuntimePHP: "Delete PHP runtime environment",
CustomAppStoreNotConfig: "Please configure the offline package address in the app store settings", CustomAppStoreNotConfig: "Please configure the offline package address in the app store settings",
CustomAppStoreNotFound: "Failed to retrieve app store package, please check if it exists", CustomAppStoreNotFound: "Failed to retrieve app store package, please check if it exists",
CustomAppStoreFileValid: "App store package must be in .tar.gz format" CustomAppStoreFileValid: "App store package must be in .tar.gz format"
PullImageTimeout: "Image pull timeout, please check the network and try again"
#file #file

View File

@ -75,6 +75,7 @@ DeleteRuntimePHP: "刪除運行環境 PHP 版本",
CustomAppStoreNotConfig: "請在應用商店設置離線包地址", CustomAppStoreNotConfig: "請在應用商店設置離線包地址",
CustomAppStoreNotFound: "應用商店包獲取失敗,請檢查是否存在", CustomAppStoreNotFound: "應用商店包獲取失敗,請檢查是否存在",
CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式" CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式"
PullImageTimeout: "拉取鏡像超時,請嘗試增加鏡像加速或更換其他鏡像加速"
#file #file

View File

@ -74,6 +74,7 @@ DeleteRuntimePHP: "删除 PHP 运行环境"
CustomAppStoreNotConfig: "请在应用商店设置离线包地址" CustomAppStoreNotConfig: "请在应用商店设置离线包地址"
CustomAppStoreNotFound: "应用商店包获取失败,请检查是否存在" CustomAppStoreNotFound: "应用商店包获取失败,请检查是否存在"
CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式" CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式"
PullImageTimeout: "拉取镜像超时,请尝试增加镜像加速或者更换其他镜像加速"
#file #file
ErrFileCanNotRead: "此文件不支持预览" ErrFileCanNotRead: "此文件不支持预览"

View File

@ -35,6 +35,7 @@ import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import { downloadFile } from '@/utils/util'; import { downloadFile } from '@/utils/util';
import { ReadByLine } from '@/api/modules/files'; import { ReadByLine } from '@/api/modules/files';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import bus from '@/global/bus';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
interface LogProps { interface LogProps {
@ -272,6 +273,7 @@ const onCloseLog = async () => {
timer = null; timer = null;
isLoading.value = false; isLoading.value = false;
emit('update:isReading', false); emit('update:isReading', false);
bus.emit('refreshTask', true);
}; };
watch( watch(

View File

@ -63,6 +63,7 @@ const openWithResourceID = (taskType: string, taskOperate: string, resourceID: n
const handleClose = () => { const handleClose = () => {
open.value = false; open.value = false;
bus.emit('refreshTask', true);
}; };
defineExpose({ openWithResourceID, openWithTaskID }); defineExpose({ openWithResourceID, openWithTaskID });

View File

@ -303,6 +303,7 @@ const message = {
healthy: 'Normal', healthy: 'Normal',
executing: 'Executing', executing: 'Executing',
installerr: 'Install Error', installerr: 'Install Error',
restating: 'Restarting',
}, },
units: { units: {
second: 'Second', second: 'Second',

View File

@ -298,6 +298,7 @@ const message = {
healthy: '正常', healthy: '正常',
executing: '執行中', executing: '執行中',
installerr: '安裝失敗', installerr: '安裝失敗',
restating: '重啟中',
}, },
units: { units: {
second: '秒', second: '秒',

View File

@ -298,6 +298,7 @@ const message = {
healthy: '正常', healthy: '正常',
executing: '执行中', executing: '执行中',
installerr: '安装失败', installerr: '安装失败',
restating: '重启中',
}, },
units: { units: {
second: '秒', second: '秒',