From 981037e2501a251fadc90936412382550671fe02 Mon Sep 17 00:00:00 2001 From: ChengPlay <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:10:01 +0800 Subject: [PATCH] fix(website): fix issue with create website with local php-fpm failed (#8379) --- agent/app/repo/runtime.go | 7 +++++++ agent/app/service/runtime.go | 9 ++++++++- agent/app/service/website_utils.go | 8 ++++---- frontend/src/components/log/compose/index.vue | 11 ++++++++++- frontend/src/components/log/file/index.vue | 1 + frontend/src/utils/runtime.ts | 12 +++++++++--- .../src/views/website/runtime/php/index.vue | 8 ++++---- frontend/src/views/website/ssl/index.vue | 3 +++ .../website/config/resource/nginx/index.vue | 2 +- .../src/views/website/website/create/index.vue | 12 ++++++++---- frontend/src/views/website/website/index.vue | 17 ++++++++--------- .../src/views/website/website/nginx/index.vue | 2 +- 12 files changed, 64 insertions(+), 28 deletions(-) diff --git a/agent/app/repo/runtime.go b/agent/app/repo/runtime.go index 234568ae5..7adc11648 100644 --- a/agent/app/repo/runtime.go +++ b/agent/app/repo/runtime.go @@ -18,6 +18,7 @@ type IRuntimeRepo interface { WithStatus(status string) DBOption WithDetailId(id uint) DBOption WithPort(port int) DBOption + WithNormalStatus(status string) DBOption Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error) Create(ctx context.Context, runtime *model.Runtime) error Save(runtime *model.Runtime) error @@ -36,6 +37,12 @@ func (r *RuntimeRepo) WithStatus(status string) DBOption { } } +func (r *RuntimeRepo) WithNormalStatus(status string) DBOption { + return func(g *gorm.DB) *gorm.DB { + return g.Where("status = ? or status = 'Normal'", status) + } +} + func (r *RuntimeRepo) WithImage(image string) DBOption { return func(g *gorm.DB) *gorm.DB { return g.Where("image = ?", image) diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index 0a9e5837e..4da272f07 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -190,7 +190,11 @@ func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.Runt opts = append(opts, repo.WithByLikeName(req.Name)) } if req.Status != "" { - opts = append(opts, runtimeRepo.WithStatus(req.Status)) + if req.Type == constant.TypePhp { + opts = append(opts, runtimeRepo.WithNormalStatus(req.Status)) + } else { + opts = append(opts, runtimeRepo.WithStatus(req.Status)) + } } if req.Type != "" { opts = append(opts, repo.WithByType(req.Type)) @@ -203,6 +207,9 @@ func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.Runt return 0, nil, err } for _, runtime := range runtimes { + if runtime.Resource == constant.ResourceLocal { + runtime.Status = constant.StatusNormal + } runtimeDTO := response.NewRuntimeDTO(runtime) runtimeDTO.Params = make(map[string]interface{}) envMap, err := gotenv.Unmarshal(runtime.Env) diff --git a/agent/app/service/website_utils.go b/agent/app/service/website_utils.go index a63320744..80add476f 100644 --- a/agent/app/service/website_utils.go +++ b/agent/app/service/website_utils.go @@ -570,14 +570,14 @@ func setListen(server *components.Server, port string, ipv6, http3, defaultServe } server.UpdateListen(port, defaultServer, params...) if ssl && http3 { - server.UpdateListen(port, defaultServer, "quic") + server.UpdateListen(port, defaultServer, "quic", "reuseport") } if !ipv6 { return } server.UpdateListen("[::]:"+port, defaultServer, params...) if ssl && http3 { - server.UpdateListen("[::]:"+port, defaultServer, "quic") + server.UpdateListen("[::]:"+port, defaultServer, "quic", "reuseport") } } @@ -713,10 +713,10 @@ func applySSL(website *model.Website, websiteSSL model.WebsiteSSL, req request.W } if !req.Http3 { for _, port := range httpsPort { - server.RemoveListen(strconv.Itoa(port), "quic") + server.RemoveListen(strconv.Itoa(port), "quic", "reuseport") if website.IPV6 { httpsPortIPV6 := "[::]:" + strconv.Itoa(port) - server.RemoveListen(httpsPortIPV6, "quic") + server.RemoveListen(httpsPortIPV6, "quic", "reuseport") } } server.RemoveDirective("add_header", []string{"Alt-Svc"}) diff --git a/frontend/src/components/log/compose/index.vue b/frontend/src/components/log/compose/index.vue index 6666da114..873138f81 100644 --- a/frontend/src/components/log/compose/index.vue +++ b/frontend/src/components/log/compose/index.vue @@ -12,7 +12,7 @@ @@ -29,12 +29,20 @@ const resource = ref(''); const globalStore = GlobalStore(); const logVisible = ref(false); const compose = ref(''); +const highlightDiff = ref(320); interface DialogProps { compose: string; resource: string; } +const defaultProps = defineProps({ + highlightDiff: { + type: Number, + default: 320, + }, +}); + const mobile = computed(() => { return globalStore.isMobile(); }); @@ -56,6 +64,7 @@ watch(logVisible, (val) => { }); const acceptParams = (props: DialogProps): void => { + highlightDiff.value = defaultProps.highlightDiff; compose.value = props.compose; resource.value = props.resource; open.value = true; diff --git a/frontend/src/components/log/file/index.vue b/frontend/src/components/log/file/index.vue index c83623ad8..d30e7a812 100644 --- a/frontend/src/components/log/file/index.vue +++ b/frontend/src/components/log/file/index.vue @@ -317,6 +317,7 @@ const containerStyle = computed(() => ({ })); onMounted(async () => { + logs.value = []; firstLoading.value = true; await init(); nextTick(() => { diff --git a/frontend/src/utils/runtime.ts b/frontend/src/utils/runtime.ts index 33041557c..feea532aa 100644 --- a/frontend/src/utils/runtime.ts +++ b/frontend/src/utils/runtime.ts @@ -3,16 +3,22 @@ import { Runtime } from '@/api/interface/runtime'; export function disabledButton(row: Runtime.Runtime, type: string): boolean { switch (type) { case 'stop': - return row.status === 'Recreating' || row.status === 'Stopped' || row.status === 'Building'; + return ( + row.status === 'Recreating' || + row.status === 'Stopped' || + row.status === 'Building' || + row.resource == 'local' + ); case 'start': return ( row.status === 'Starting' || row.status === 'Recreating' || row.status === 'Running' || - row.status === 'Building' + row.status === 'Building' || + row.resource == 'local' ); case 'restart': - return row.status === 'Recreating' || row.status === 'Building'; + return row.status === 'Recreating' || row.status === 'Building' || row.resource == 'local'; case 'edit': return row.status === 'Recreating' || row.status === 'Building'; case 'extension': diff --git a/frontend/src/views/website/runtime/php/index.vue b/frontend/src/views/website/runtime/php/index.vue index 71599ad09..3a33e462e 100644 --- a/frontend/src/views/website/runtime/php/index.vue +++ b/frontend/src/views/website/runtime/php/index.vue @@ -96,11 +96,11 @@ - + - + @@ -262,12 +262,12 @@ const openLog = (row: Runtime.RuntimeDTO) => { if (row.status == 'Running') { composeLogRef.value.acceptParams({ compose: row.path + '/docker-compose.yml', resource: row.name }); } else { - logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'Building', heightDiff: 220 }); + logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'Building' }); } }; const openCreateLog = (id: number) => { - logRef.value.acceptParams({ id: id, type: 'php', tail: true, heightDiff: 220 }); + logRef.value.acceptParams({ id: id, type: 'php', tail: true }); }; const openExtensions = () => { diff --git a/frontend/src/views/website/ssl/index.vue b/frontend/src/views/website/ssl/index.vue index e085d42e8..f03f54476 100644 --- a/frontend/src/views/website/ssl/index.vue +++ b/frontend/src/views/website/ssl/index.vue @@ -22,6 +22,9 @@ {{ $t('commons.button.delete') }} +