Skip to content

Commit

Permalink
feat(appstore): Handle container restarting status for App
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed Jan 9, 2025
1 parent 022580b commit 9f35247
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions agent/app/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
if taskErr := installTask.Execute(); taskErr != nil {
appInstall.Status = constant.InstallErr
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)
}
}()
Expand Down
5 changes: 5 additions & 0 deletions agent/app/service/app_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
exitedCount := 0
pausedCount := 0
runningCount := 0
restartingCount := 0
total := len(containerNames)
for _, name := range containerNames {
if con, ok := containers["/"+name]; ok {
Expand All @@ -1347,6 +1348,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
exitNames = append(exitNames, name)
case "running":
runningCount++
case "restarting":
restartingCount++
case "paused":
pausedCount++
}
Expand All @@ -1362,6 +1365,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI
if oldStatus == constant.Running {
return
}
case restartingCount == total:
appInstall.Status = constant.Restating
case pausedCount == total:
appInstall.Status = constant.Paused
case len(notFoundNames) == total:
Expand Down
1 change: 1 addition & 0 deletions agent/constant/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
UpErr = "UpErr"
InstallErr = "InstallErr"
Uninstalling = "Uninstalling"
Restating = "Restarting"

ContainerPrefix = "1Panel-"

Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ DeleteRuntimePHP: "Delete PHP runtime environment",
CustomAppStoreNotConfig: "Please configure the offline package address in the app store settings",
CustomAppStoreNotFound: "Failed to retrieve app store package, please check if it exists",
CustomAppStoreFileValid: "App store package must be in .tar.gz format"
PullImageTimeout: "Image pull timeout, please check the network and try again"


#file
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ DeleteRuntimePHP: "刪除運行環境 PHP 版本",
CustomAppStoreNotConfig: "請在應用商店設置離線包地址",
CustomAppStoreNotFound: "應用商店包獲取失敗,請檢查是否存在",
CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式"
PullImageTimeout: "拉取鏡像超時,請嘗試增加鏡像加速或更換其他鏡像加速"


#file
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ DeleteRuntimePHP: "删除 PHP 运行环境"
CustomAppStoreNotConfig: "请在应用商店设置离线包地址"
CustomAppStoreNotFound: "应用商店包获取失败,请检查是否存在"
CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式"
PullImageTimeout: "拉取镜像超时,请尝试增加镜像加速或者更换其他镜像加速"

#file
ErrFileCanNotRead: "此文件不支持预览"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/log-file/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import { downloadFile } from '@/utils/util';
import { ReadByLine } from '@/api/modules/files';
import { GlobalStore } from '@/store';
import bus from '@/global/bus';
const globalStore = GlobalStore();
interface LogProps {
Expand Down Expand Up @@ -272,6 +273,7 @@ const onCloseLog = async () => {
timer = null;
isLoading.value = false;
emit('update:isReading', false);
bus.emit('refreshTask', true);
};
watch(
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/task-log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const openWithResourceID = (taskType: string, taskOperate: string, resourceID: n
const handleClose = () => {
open.value = false;
bus.emit('refreshTask', true);
};
defineExpose({ openWithResourceID, openWithTaskID });
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ const message = {
healthy: 'Normal',
executing: 'Executing',
installerr: 'Install Error',
restating: 'Restarting',
},
units: {
second: 'Second',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const message = {
healthy: '正',
executing: '執行中',
installerr: '安裝失敗',
restating: '重啟中',
},
units: {
second: '秒',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const message = {
healthy: '正',
executing: '执行中',
installerr: '安装失败',
restating: '重启中',
},
units: {
second: '秒',
Expand Down

0 comments on commit 9f35247

Please sign in to comment.