fix(website): fix issue with create website with local php-fpm failed (#8379)

This commit is contained in:
ChengPlay 2025-04-11 15:10:01 +08:00 committed by GitHub
parent ce4a770e23
commit 981037e250
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 64 additions and 28 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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"})

View file

@ -12,7 +12,7 @@
</el-tooltip>
</template>
<template #content>
<ContainerLog :compose="compose" :resource="resource" />
<ContainerLog :compose="compose" :resource="resource" :highlightDiff="highlightDiff" />
</template>
</DrawerPro>
</template>
@ -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;

View file

@ -317,6 +317,7 @@ const containerStyle = computed(() => ({
}));
onMounted(async () => {
logs.value = [];
firstLoading.value = true;
await init();
nextTick(() => {

View file

@ -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':

View file

@ -96,11 +96,11 @@
<CreateRuntime ref="createRef" @close="search" @submit="openCreateLog" />
<OpDialog ref="opRef" @search="search" />
<Log ref="logRef" @close="search" :heightDiff="280" />
<Log ref="logRef" @close="search" :heightDiff="200" />
<Extensions ref="extensionsRef" @close="search" />
<AppResources ref="checkRef" @close="search" />
<ExtManagement ref="extManagementRef" />
<ComposeLogs ref="composeLogRef" />
<ComposeLogs ref="composeLogRef" :highlightDiff="400" />
<Config ref="configRef" />
<Supervisor ref="supervisorRef" />
</div>
@ -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 = () => {

View file

@ -22,6 +22,9 @@
{{ $t('commons.button.delete') }}
</el-button>
</template>
<template #rightToolBar>
<TableRefresh @search="search()" />
</template>
<template #main>
<ComplexTable
:data="data"

View file

@ -1,6 +1,6 @@
<template>
<div v-loading="loading">
<CodemirrorPro v-model="content" mode="nginx" />
<CodemirrorPro v-model="content" mode="nginx" :heightDiff="400" />
<el-button type="primary" @click="submit()" class="mt-2.5">
{{ $t('nginx.saveAndReload') }}
</el-button>

View file

@ -606,7 +606,7 @@ const initData = () => ({
ftpUser: '',
ftpPassword: '',
proxyType: 'tcp',
port: 0,
port: 9000,
proxyProtocol: 'http://',
proxyAddress: '',
runtimeType: 'php',
@ -808,9 +808,13 @@ const changeRuntime = (runID: number) => {
runtimes.value.forEach((item) => {
if (item.id === runID) {
runtimeResource.value = item.resource;
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
if (runtimePorts.value.length > 0) {
website.value.port = runtimePorts.value[0];
if (runtimeResource.value == 'local') {
website.value.port = 9000;
} else {
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
if (runtimePorts.value.length > 0) {
website.value.port = runtimePorts.value[0];
}
}
}
});

View file

@ -51,15 +51,14 @@
</div>
</el-select>
<TableSearch @search="search()" v-model:searchName="req.name" />
<div class="!ml-2.5">
<fu-table-column-select
:columns="columns"
trigger="hover"
:title="$t('commons.table.selectColumn')"
popper-class="popper-class"
:only-icon="true"
/>
</div>
<TableRefresh @search="search()" />
<fu-table-column-select
:columns="columns"
trigger="hover"
:title="$t('commons.table.selectColumn')"
popper-class="popper-class"
:only-icon="true"
/>
</template>
<template v-if="!openNginxConfig" #main>
<ComplexTable

View file

@ -31,7 +31,7 @@
<Status v-if="activeName === '1'" :status="status" />
<Source v-if="activeName === '2'" />
<NginxPer v-if="activeName === '3'" />
<ContainerLog v-if="activeName === '4'" :container="containerName" />
<ContainerLog v-if="activeName === '4'" :container="containerName" :highlightDiff="350" />
<Module v-if="activeName === '5'" />
</template>
</LayoutContent>