diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index c9ebedd44..271d7b688 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -4,7 +4,9 @@ import ( "context" "encoding/json" "fmt" + "github.com/1Panel-dev/1Panel/backend/utils/files" "github.com/docker/docker/api/types" + "gopkg.in/yaml.v3" "math" "os" "path" @@ -12,10 +14,6 @@ import ( "sort" "strconv" "strings" - "time" - - "github.com/1Panel-dev/1Panel/backend/utils/files" - "gopkg.in/yaml.v3" "github.com/1Panel-dev/1Panel/backend/utils/env" "github.com/1Panel-dev/1Panel/backend/utils/nginx" @@ -703,15 +701,6 @@ func (a *AppInstallService) GetParams(id uint) (*response.AppConfig, error) { return &res, nil } -func measureExecutionTime(name string, fn func() error) error { - start := time.Now() // 记录开始时间 - err := fn() // 执行函数 - elapsed := time.Since(start) // 计算执行时间 - - fmt.Printf("%s took %s\n", name, elapsed) // 输出函数名和执行时间 - return err -} - func syncAppInstallStatus(appInstall *model.AppInstall) error { if appInstall.Status == constant.Installing || appInstall.Status == constant.Rebuilding || appInstall.Status == constant.Upgrading { return nil diff --git a/backend/utils/docker/compose.go b/backend/utils/docker/compose.go index ffe145780..6b78c59a0 100644 --- a/backend/utils/docker/compose.go +++ b/backend/utils/docker/compose.go @@ -2,19 +2,13 @@ package docker import ( "context" + "github.com/compose-spec/compose-go/v2/loader" + "github.com/compose-spec/compose-go/v2/types" + "github.com/docker/compose/v2/pkg/api" + "github.com/joho/godotenv" "path" "regexp" "strings" - "time" - - "github.com/compose-spec/compose-go/v2/loader" - "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/flags" - "github.com/docker/compose/v2/pkg/api" - "github.com/docker/compose/v2/pkg/compose" - "github.com/docker/docker/client" - "github.com/joho/godotenv" ) type ComposeService struct { @@ -22,47 +16,6 @@ type ComposeService struct { project *types.Project } -func UpComposeProject(project *types.Project) error { - for i, s := range project.Services { - s.CustomLabels = map[string]string{ - api.ProjectLabel: project.Name, - api.ServiceLabel: s.Name, - api.VersionLabel: api.ComposeVersion, - api.WorkingDirLabel: project.WorkingDir, - api.ConfigFilesLabel: strings.Join(project.ComposeFiles, ","), - api.OneoffLabel: "False", - } - project.Services[i] = s - } - - apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) - if err != nil { - return err - } - var ops []command.CLIOption - ops = append(ops, command.WithAPIClient(apiClient), command.WithDefaultContextStoreConfig()) - cli, err := command.NewDockerCli(ops...) - if err != nil { - return err - } - cliOp := flags.NewClientOptions() - if err = cli.Initialize(cliOp); err != nil { - return err - } - service := compose.NewComposeService(cli) - composeService := ComposeService{Service: service} - - return composeService.Up(context.Background(), project, api.UpOptions{ - Create: api.CreateOptions{ - Timeout: getComposeTimeout(), - }, - Start: api.StartOptions{ - WaitTimeout: *getComposeTimeout(), - Wait: true, - }, - }) -} - func GetComposeProject(projectName, workDir string, yml []byte, env []byte, skipNormalization bool) (*types.Project, error) { var configFiles []types.ConfigFile configFiles = append(configFiles, types.ConfigFile{ @@ -93,11 +46,6 @@ func GetComposeProject(projectName, workDir string, yml []byte, env []byte, skip return project, nil } -func getComposeTimeout() *time.Duration { - timeout := time.Minute * time.Duration(10) - return &timeout -} - type ComposeProject struct { Version string Services map[string]Service `yaml:"services"` diff --git a/backend/utils/postgresql/client.go b/backend/utils/postgresql/client.go index 1edc5d7f6..2122c28bb 100644 --- a/backend/utils/postgresql/client.go +++ b/backend/utils/postgresql/client.go @@ -3,6 +3,7 @@ package postgresql import ( "context" "database/sql" + "errors" "fmt" "time" @@ -42,7 +43,7 @@ func NewPostgresqlClient(conn client.DBInfo) (PostgresqlClient, error) { if err := db.PingContext(ctx); err != nil { return nil, err } - if ctx.Err() == context.DeadlineExceeded { + if errors.Is(ctx.Err(), context.DeadlineExceeded) { return nil, buserr.New(constant.ErrExecTimeOut) } diff --git a/frontend/src/views/website/runtime/node/operate/index.vue b/frontend/src/views/website/runtime/node/operate/index.vue index afca4f90a..5e08d2a9f 100644 --- a/frontend/src/views/website/runtime/node/operate/index.vue +++ b/frontend/src/views/website/runtime/node/operate/index.vue @@ -165,6 +165,7 @@ + @@ -206,7 +207,7 @@ import { Rules, checkNumberRange } from '@/global/form-rules'; import i18n from '@/lang'; import { MsgError, MsgSuccess } from '@/utils/message'; import { FormInstance } from 'element-plus'; -import { reactive, ref, watch } from 'vue'; +import { computed, reactive, ref, watch } from 'vue'; import DrawerHeader from '@/components/drawer-header/index.vue'; interface OperateRrops { @@ -263,6 +264,13 @@ const rules = ref({ const scripts = ref([]); const em = defineEmits(['close']); +const hasPnpm = computed(() => { + if (runtime.version == undefined) { + return false; + } + return parseFloat(runtime.version) > 18; +}); + const imageSources = [ { label: i18n.global.t('runtime.default'),