diff --git a/backend/app/service/website.go b/backend/app/service/website.go index b70af3e00..d4f2bd4ac 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -9,9 +9,6 @@ import ( "encoding/pem" "errors" "fmt" - "github.com/1Panel-dev/1Panel/backend/i18n" - "github.com/1Panel-dev/1Panel/backend/utils/common" - "github.com/spf13/afero" "os" "path" "reflect" @@ -21,6 +18,10 @@ import ( "syscall" "time" + "github.com/1Panel-dev/1Panel/backend/i18n" + "github.com/1Panel-dev/1Panel/backend/utils/common" + "github.com/spf13/afero" + "github.com/1Panel-dev/1Panel/backend/utils/compose" "github.com/1Panel-dev/1Panel/backend/utils/env" @@ -816,7 +817,7 @@ func (w WebsiteService) PreInstallCheck(req request.WebsiteInstallCheckReq) ([]r checkIds = append(req.InstallIds, appInstall.ID) } for _, id := range checkIds { - if err := syncById(id); err != nil { + if err := syncByID(id); err != nil { return nil, err } } diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index d1ad48f4a..be2878dd5 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -1,6 +1,7 @@ import http from '@/api'; import { ResPage } from '../interface'; import { App } from '../interface/app'; +import { TimeoutEnum } from '@/enums/http-enum'; export const SyncApp = () => { return http.post('apps/sync', {}); @@ -67,7 +68,7 @@ export const GetAppInstalled = (search: App.AppInstalledSearch) => { }; export const InstalledOp = (op: App.AppInstalledOp) => { - return http.post('apps/installed/op', op, 40000); + return http.post('apps/installed/op', op, TimeoutEnum.T_40S); }; export const SyncInstalledApp = () => { diff --git a/frontend/src/api/modules/container.ts b/frontend/src/api/modules/container.ts index 4e0798219..90308f8c8 100644 --- a/frontend/src/api/modules/container.ts +++ b/frontend/src/api/modules/container.ts @@ -1,9 +1,10 @@ import http from '@/api'; import { ResPage, SearchWithPage } from '../interface'; import { Container } from '../interface/container'; +import { TimeoutEnum } from '@/enums/http-enum'; export const searchContainer = (params: Container.ContainerSearch) => { - return http.post>(`/containers/search`, params, 400000); + return http.post>(`/containers/search`, params, TimeoutEnum.T_40S); }; export const listContainer = () => { return http.post>(`/containers/list`, {}); @@ -12,13 +13,13 @@ export const loadResourceLimit = () => { return http.get(`/containers/limit`); }; export const createContainer = (params: Container.ContainerHelper) => { - return http.post(`/containers`, params, 3000000); + return http.post(`/containers`, params, TimeoutEnum.T_10M); }; export const updateContainer = (params: Container.ContainerHelper) => { - return http.post(`/containers/update`, params, 3000000); + return http.post(`/containers/update`, params, TimeoutEnum.T_10M); }; export const upgradeContainer = (name: string, image: string, forcePull: boolean) => { - return http.post(`/containers/upgrade`, { name: name, image: image, forcePull: forcePull }, 3000000); + return http.post(`/containers/upgrade`, { name: name, image: image, forcePull: forcePull }, TimeoutEnum.T_10M); }; export const loadContainerInfo = (name: string) => { return http.post(`/containers/info`, { name: name }); @@ -62,10 +63,10 @@ export const imagePush = (params: Container.ImagePush) => { return http.post(`/containers/image/push`, params); }; export const imageLoad = (params: Container.ImageLoad) => { - return http.post(`/containers/image/load`, params, 1200000); + return http.post(`/containers/image/load`, params, TimeoutEnum.T_10M); }; export const imageSave = (params: Container.ImageSave) => { - return http.post(`/containers/image/save`, params, 1200000); + return http.post(`/containers/image/save`, params, TimeoutEnum.T_10M); }; export const imageTag = (params: Container.ImageTag) => { return http.post(`/containers/image/tag`, params); @@ -104,7 +105,7 @@ export const createVolume = (params: Container.VolumeCreate) => { // repo export const checkRepoStatus = (id: number) => { - return http.post(`/containers/repo/status`, { id: id }, 40000); + return http.post(`/containers/repo/status`, { id: id }, TimeoutEnum.T_40S); }; export const searchImageRepo = (params: SearchWithPage) => { return http.post>(`/containers/repo/search`, params); @@ -113,13 +114,13 @@ export const listImageRepo = () => { return http.get(`/containers/repo`); }; export const createImageRepo = (params: Container.RepoCreate) => { - return http.post(`/containers/repo`, params, 40000); + return http.post(`/containers/repo`, params, TimeoutEnum.T_40S); }; export const updateImageRepo = (params: Container.RepoUpdate) => { - return http.post(`/containers/repo/update`, params, 40000); + return http.post(`/containers/repo/update`, params, TimeoutEnum.T_40S); }; export const deleteImageRepo = (params: Container.RepoDelete) => { - return http.post(`/containers/repo/del`, params, 40000); + return http.post(`/containers/repo/del`, params, TimeoutEnum.T_40S); }; // composeTemplate @@ -153,7 +154,7 @@ export const composeOperator = (params: Container.ComposeOpration) => { return http.post(`/containers/compose/operate`, params); }; export const composeUpdate = (params: Container.ComposeUpdate) => { - return http.post(`/containers/compose/update`, params, 600000); + return http.post(`/containers/compose/update`, params, TimeoutEnum.T_10M); }; // docker @@ -170,10 +171,10 @@ export const loadDockerStatus = () => { return http.get(`/containers/docker/status`); }; export const updateDaemonJson = (key: string, value: string) => { - return http.post(`/containers/daemonjson/update`, { key: key, value: value }, 60000); + return http.post(`/containers/daemonjson/update`, { key: key, value: value }, TimeoutEnum.T_60S); }; export const updateLogOption = (maxSize: string, maxFile: string) => { - return http.post(`/containers/logoption/update`, { logMaxSize: maxSize, logMaxFile: maxFile }, 60000); + return http.post(`/containers/logoption/update`, { logMaxSize: maxSize, logMaxFile: maxFile }, TimeoutEnum.T_60S); }; export const updateDaemonJsonByfile = (params: Container.DaemonJsonUpdateByFile) => { return http.post(`/containers/daemonjson/update/byfile`, params); diff --git a/frontend/src/api/modules/cronjob.ts b/frontend/src/api/modules/cronjob.ts index df16e99d6..67674b539 100644 --- a/frontend/src/api/modules/cronjob.ts +++ b/frontend/src/api/modules/cronjob.ts @@ -1,6 +1,7 @@ import http from '@/api'; import { ResPage, SearchWithPage } from '../interface'; import { Cronjob } from '../interface/cronjob'; +import { TimeoutEnum } from '@/enums/http-enum'; export const getCronjobPage = (params: SearchWithPage) => { return http.post>(`/cronjobs/search`, params); @@ -39,10 +40,13 @@ export const updateStatus = (params: Cronjob.UpdateStatus) => { }; export const downloadRecordCheck = (params: Cronjob.Download) => { - return http.post(`cronjobs/download`, params, 40000); + return http.post(`cronjobs/download`, params, TimeoutEnum.T_40S); }; export const downloadRecord = (params: Cronjob.Download) => { - return http.download(`cronjobs/download`, params, { responseType: 'blob', timeout: 40000 }); + return http.download(`cronjobs/download`, params, { + responseType: 'blob', + timeout: TimeoutEnum.T_40S, + }); }; export const handleOnce = (id: number) => { diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index 98650dee8..38489fa85 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -3,6 +3,7 @@ import { deepCopy } from '@/utils/util'; import { Base64 } from 'js-base64'; import { ResPage, DescriptionUpdate } from '../interface'; import { Database } from '../interface/database'; +import { TimeoutEnum } from '@/enums/http-enum'; export const searchMysqlDBs = (params: Database.SearchDBWithPage) => { return http.post>(`/databases/search`, params); @@ -101,13 +102,13 @@ export const listDatabases = (type: string) => { return http.get>(`/databases/db/list/${type}`); }; export const checkDatabase = (params: Database.DatabaseCreate) => { - return http.post(`/databases/db/check`, params, 40000); + return http.post(`/databases/db/check`, params, TimeoutEnum.T_40S); }; export const addDatabase = (params: Database.DatabaseCreate) => { - return http.post(`/databases/db`, params, 40000); + return http.post(`/databases/db`, params, TimeoutEnum.T_40S); }; export const editDatabase = (params: Database.DatabaseUpdate) => { - return http.post(`/databases/db/update`, params, 40000); + return http.post(`/databases/db/update`, params, TimeoutEnum.T_40S); }; export const deleteDatabase = (id: number) => { return http.post(`/databases/db/del`, { id: id }); diff --git a/frontend/src/api/modules/files.ts b/frontend/src/api/modules/files.ts index a33a37603..3f0ea9fdd 100644 --- a/frontend/src/api/modules/files.ts +++ b/frontend/src/api/modules/files.ts @@ -2,9 +2,10 @@ import { File } from '@/api/interface/file'; import http from '@/api'; import { AxiosRequestConfig } from 'axios'; import { ResPage } from '../interface'; +import { TimeoutEnum } from '@/enums/http-enum'; export const GetFilesList = (params: File.ReqFile) => { - return http.post('files/search', params, 200000); + return http.post('files/search', params, TimeoutEnum.T_5M); }; export const GetUploadList = (params: File.SearchUploadInfo) => { @@ -76,7 +77,7 @@ export const MoveFile = (params: File.FileMove) => { }; export const DownloadFile = (params: File.FileDownload) => { - return http.download('files/download', params, { responseType: 'blob', timeout: 20000 }); + return http.download('files/download', params, { responseType: 'blob', timeout: TimeoutEnum.T_40S }); }; export const ComputeDirSize = (params: File.DirSizeReq) => { diff --git a/frontend/src/api/modules/host-tool.ts b/frontend/src/api/modules/host-tool.ts index c365704c0..c15064387 100644 --- a/frontend/src/api/modules/host-tool.ts +++ b/frontend/src/api/modules/host-tool.ts @@ -1,5 +1,6 @@ import http from '@/api'; import { HostTool } from '../interface/host-tool'; +import { TimeoutEnum } from '@/enums/http-enum'; export const GetSupervisorStatus = () => { return http.post(`/hosts/tool`, { type: 'supervisord', operate: 'status' }); @@ -26,11 +27,11 @@ export const CreateSupervisorProcess = (req: HostTool.SupersivorProcess) => { }; export const OperateSupervisorProcess = (req: HostTool.ProcessReq) => { - return http.post(`/hosts/tool/supervisor/process`, req, 100000); + return http.post(`/hosts/tool/supervisor/process`, req, TimeoutEnum.T_60S); }; export const LoadProcessStatus = () => { - return http.post>(`/hosts/tool/supervisor/process/load`, {}, 40000); + return http.post>(`/hosts/tool/supervisor/process/load`, {}, TimeoutEnum.T_40S); }; export const GetSupervisorProcess = () => { @@ -38,5 +39,5 @@ export const GetSupervisorProcess = () => { }; export const OperateSupervisorProcessFile = (req: HostTool.ProcessFileReq) => { - return http.post(`/hosts/tool/supervisor/process/file`, req, 100000); + return http.post(`/hosts/tool/supervisor/process/file`, req, TimeoutEnum.T_60S); }; diff --git a/frontend/src/api/modules/host.ts b/frontend/src/api/modules/host.ts index 52cd0f915..88ec5ee96 100644 --- a/frontend/src/api/modules/host.ts +++ b/frontend/src/api/modules/host.ts @@ -4,6 +4,7 @@ import { Command } from '../interface/command'; import { Host } from '../interface/host'; import { Base64 } from 'js-base64'; import { deepCopy } from '@/utils/util'; +import { TimeoutEnum } from '@/enums/http-enum'; export const searchHosts = (params: Host.SearchWithPage) => { return http.post>(`/hosts/search`, params); @@ -73,28 +74,28 @@ export const loadFireBaseInfo = () => { return http.get(`/hosts/firewall/base`); }; export const searchFireRule = (params: Host.RuleSearch) => { - return http.post>(`/hosts/firewall/search`, params); + return http.post>(`/hosts/firewall/search`, params, TimeoutEnum.T_40S); }; export const operateFire = (operation: string) => { - return http.post(`/hosts/firewall/operate`, { operation: operation }, 40000); + return http.post(`/hosts/firewall/operate`, { operation: operation }, TimeoutEnum.T_40S); }; export const operatePortRule = (params: Host.RulePort) => { - return http.post(`/hosts/firewall/port`, params); + return http.post(`/hosts/firewall/port`, params, TimeoutEnum.T_40S); }; export const operateIPRule = (params: Host.RuleIP) => { - return http.post(`/hosts/firewall/ip`, params); + return http.post(`/hosts/firewall/ip`, params, TimeoutEnum.T_40S); }; export const updatePortRule = (params: Host.UpdatePortRule) => { - return http.post(`/hosts/firewall/update/port`, params); + return http.post(`/hosts/firewall/update/port`, params, TimeoutEnum.T_40S); }; export const updateAddrRule = (params: Host.UpdateAddrRule) => { - return http.post(`/hosts/firewall/update/addr`, params); + return http.post(`/hosts/firewall/update/addr`, params, TimeoutEnum.T_40S); }; export const updateFirewallDescription = (params: Host.UpdateDescription) => { return http.post(`/hosts/firewall/update/description`, params); }; export const batchOperateRule = (params: Host.BatchRule) => { - return http.post(`/hosts/firewall/batch`, params); + return http.post(`/hosts/firewall/batch`, params, TimeoutEnum.T_60S); }; // ssh diff --git a/frontend/src/api/modules/setting.ts b/frontend/src/api/modules/setting.ts index 8750ec75d..5e115216c 100644 --- a/frontend/src/api/modules/setting.ts +++ b/frontend/src/api/modules/setting.ts @@ -4,6 +4,7 @@ import { Base64 } from 'js-base64'; import { ResPage, SearchWithPage, DescriptionUpdate } from '../interface'; import { Backup } from '../interface/backup'; import { Setting } from '../interface/setting'; +import { TimeoutEnum } from '@/enums/http-enum'; export const getSettingInfo = () => { return http.post(`/settings/search`); @@ -67,16 +68,16 @@ export const loadBaseDir = () => { // backup export const handleBackup = (params: Backup.Backup) => { - return http.post(`/settings/backup/backup`, params, 3600000); + return http.post(`/settings/backup/backup`, params, TimeoutEnum.T_1H); }; export const handleRecover = (params: Backup.Recover) => { - return http.post(`/settings/backup/recover`, params, 86400000); + return http.post(`/settings/backup/recover`, params, TimeoutEnum.T_1D); }; export const handleRecoverByUpload = (params: Backup.Recover) => { - return http.post(`/settings/backup/recover/byupload`, params, 86400000); + return http.post(`/settings/backup/recover/byupload`, params, TimeoutEnum.T_1D); }; export const downloadBackupRecord = (params: Backup.RecordDownload) => { - return http.post(`/settings/backup/record/download`, params, 600000); + return http.post(`/settings/backup/record/download`, params, TimeoutEnum.T_10M); }; export const deleteBackupRecord = (params: { ids: number[] }) => { return http.post(`/settings/backup/record/del`, params); diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index eae941a36..fadb2d18f 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -2,6 +2,7 @@ import http from '@/api'; import { ReqPage, ResPage } from '../interface'; import { Website } from '../interface/website'; import { File } from '../interface/file'; +import { TimeoutEnum } from '@/enums/http-enum'; export const SearchWebsites = (req: Website.WebSiteSearch) => { return http.post>(`/websites/search`, req); @@ -100,7 +101,7 @@ export const ListSSL = (req: Website.SSLReq) => { }; export const CreateSSL = (req: Website.SSLCreate) => { - return http.post(`/websites/ssl`, req, 100000); + return http.post(`/websites/ssl`, req, TimeoutEnum.T_60S); }; export const DeleteSSL = (req: Website.DelReq) => { @@ -128,7 +129,7 @@ export const UpdateSSL = (req: Website.SSLUpdate) => { }; export const GetDnsResolve = (req: Website.DNSResolveReq) => { - return http.post(`/websites/ssl/resolve`, req, 60000); + return http.post(`/websites/ssl/resolve`, req, TimeoutEnum.T_60S); }; export const GetHTTPSConfig = (id: number) => { diff --git a/frontend/src/enums/http-enum.ts b/frontend/src/enums/http-enum.ts index b8086b693..68105ef25 100644 --- a/frontend/src/enums/http-enum.ts +++ b/frontend/src/enums/http-enum.ts @@ -13,6 +13,14 @@ export enum ResultEnum { TYPE = 'success', } +export enum TimeoutEnum { + T_40S = 40000, + T_60S = 60000, + T_5M = 300000, + T_10M = 600000, + T_1H = 3600000, + T_1D = 86400000, +} /** * @description:请求方法 */