Skip to content

Commit d318ceb

Browse files
fix(website): fix issue with create website with local php-fpm failed
1 parent 04f1722 commit d318ceb

File tree

12 files changed

+64
-28
lines changed

12 files changed

+64
-28
lines changed

agent/app/repo/runtime.go

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type IRuntimeRepo interface {
1818
WithStatus(status string) DBOption
1919
WithDetailId(id uint) DBOption
2020
WithPort(port int) DBOption
21+
WithNormalStatus(status string) DBOption
2122
Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error)
2223
Create(ctx context.Context, runtime *model.Runtime) error
2324
Save(runtime *model.Runtime) error
@@ -36,6 +37,12 @@ func (r *RuntimeRepo) WithStatus(status string) DBOption {
3637
}
3738
}
3839

40+
func (r *RuntimeRepo) WithNormalStatus(status string) DBOption {
41+
return func(g *gorm.DB) *gorm.DB {
42+
return g.Where("status = ? or status = 'Normal'", status)
43+
}
44+
}
45+
3946
func (r *RuntimeRepo) WithImage(image string) DBOption {
4047
return func(g *gorm.DB) *gorm.DB {
4148
return g.Where("image = ?", image)

agent/app/service/runtime.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.Runt
190190
opts = append(opts, repo.WithByLikeName(req.Name))
191191
}
192192
if req.Status != "" {
193-
opts = append(opts, runtimeRepo.WithStatus(req.Status))
193+
if req.Type == constant.TypePhp {
194+
opts = append(opts, runtimeRepo.WithNormalStatus(req.Status))
195+
} else {
196+
opts = append(opts, runtimeRepo.WithStatus(req.Status))
197+
}
194198
}
195199
if req.Type != "" {
196200
opts = append(opts, repo.WithByType(req.Type))
@@ -203,6 +207,9 @@ func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.Runt
203207
return 0, nil, err
204208
}
205209
for _, runtime := range runtimes {
210+
if runtime.Resource == constant.ResourceLocal {
211+
runtime.Status = constant.StatusNormal
212+
}
206213
runtimeDTO := response.NewRuntimeDTO(runtime)
207214
runtimeDTO.Params = make(map[string]interface{})
208215
envMap, err := gotenv.Unmarshal(runtime.Env)

agent/app/service/website_utils.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,14 @@ func setListen(server *components.Server, port string, ipv6, http3, defaultServe
570570
}
571571
server.UpdateListen(port, defaultServer, params...)
572572
if ssl && http3 {
573-
server.UpdateListen(port, defaultServer, "quic")
573+
server.UpdateListen(port, defaultServer, "quic", "reuseport")
574574
}
575575
if !ipv6 {
576576
return
577577
}
578578
server.UpdateListen("[::]:"+port, defaultServer, params...)
579579
if ssl && http3 {
580-
server.UpdateListen("[::]:"+port, defaultServer, "quic")
580+
server.UpdateListen("[::]:"+port, defaultServer, "quic", "reuseport")
581581
}
582582
}
583583

@@ -713,10 +713,10 @@ func applySSL(website *model.Website, websiteSSL model.WebsiteSSL, req request.W
713713
}
714714
if !req.Http3 {
715715
for _, port := range httpsPort {
716-
server.RemoveListen(strconv.Itoa(port), "quic")
716+
server.RemoveListen(strconv.Itoa(port), "quic", "reuseport")
717717
if website.IPV6 {
718718
httpsPortIPV6 := "[::]:" + strconv.Itoa(port)
719-
server.RemoveListen(httpsPortIPV6, "quic")
719+
server.RemoveListen(httpsPortIPV6, "quic", "reuseport")
720720
}
721721
}
722722
server.RemoveDirective("add_header", []string{"Alt-Svc"})

frontend/src/components/log/compose/index.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</el-tooltip>
1313
</template>
1414
<template #content>
15-
<ContainerLog :compose="compose" :resource="resource" />
15+
<ContainerLog :compose="compose" :resource="resource" :highlightDiff="highlightDiff" />
1616
</template>
1717
</DrawerPro>
1818
</template>
@@ -29,12 +29,20 @@ const resource = ref('');
2929
const globalStore = GlobalStore();
3030
const logVisible = ref(false);
3131
const compose = ref('');
32+
const highlightDiff = ref(320);
3233
3334
interface DialogProps {
3435
compose: string;
3536
resource: string;
3637
}
3738
39+
const defaultProps = defineProps({
40+
highlightDiff: {
41+
type: Number,
42+
default: 320,
43+
},
44+
});
45+
3846
const mobile = computed(() => {
3947
return globalStore.isMobile();
4048
});
@@ -56,6 +64,7 @@ watch(logVisible, (val) => {
5664
});
5765
5866
const acceptParams = (props: DialogProps): void => {
67+
highlightDiff.value = defaultProps.highlightDiff;
5968
compose.value = props.compose;
6069
resource.value = props.resource;
6170
open.value = true;

frontend/src/components/log/file/index.vue

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ const containerStyle = computed(() => ({
317317
}));
318318
319319
onMounted(async () => {
320+
logs.value = [];
320321
firstLoading.value = true;
321322
await init();
322323
nextTick(() => {

frontend/src/utils/runtime.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ import { Runtime } from '@/api/interface/runtime';
33
export function disabledButton(row: Runtime.Runtime, type: string): boolean {
44
switch (type) {
55
case 'stop':
6-
return row.status === 'Recreating' || row.status === 'Stopped' || row.status === 'Building';
6+
return (
7+
row.status === 'Recreating' ||
8+
row.status === 'Stopped' ||
9+
row.status === 'Building' ||
10+
row.resource == 'local'
11+
);
712
case 'start':
813
return (
914
row.status === 'Starting' ||
1015
row.status === 'Recreating' ||
1116
row.status === 'Running' ||
12-
row.status === 'Building'
17+
row.status === 'Building' ||
18+
row.resource == 'local'
1319
);
1420
case 'restart':
15-
return row.status === 'Recreating' || row.status === 'Building';
21+
return row.status === 'Recreating' || row.status === 'Building' || row.resource == 'local';
1622
case 'edit':
1723
return row.status === 'Recreating' || row.status === 'Building';
1824
case 'extension':

frontend/src/views/website/runtime/php/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@
9696

9797
<CreateRuntime ref="createRef" @close="search" @submit="openCreateLog" />
9898
<OpDialog ref="opRef" @search="search" />
99-
<Log ref="logRef" @close="search" :heightDiff="280" />
99+
<Log ref="logRef" @close="search" :heightDiff="200" />
100100
<Extensions ref="extensionsRef" @close="search" />
101101
<AppResources ref="checkRef" @close="search" />
102102
<ExtManagement ref="extManagementRef" />
103-
<ComposeLogs ref="composeLogRef" />
103+
<ComposeLogs ref="composeLogRef" :highlightDiff="400" />
104104
<Config ref="configRef" />
105105
<Supervisor ref="supervisorRef" />
106106
</div>
@@ -262,12 +262,12 @@ const openLog = (row: Runtime.RuntimeDTO) => {
262262
if (row.status == 'Running') {
263263
composeLogRef.value.acceptParams({ compose: row.path + '/docker-compose.yml', resource: row.name });
264264
} else {
265-
logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'Building', heightDiff: 220 });
265+
logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'Building' });
266266
}
267267
};
268268
269269
const openCreateLog = (id: number) => {
270-
logRef.value.acceptParams({ id: id, type: 'php', tail: true, heightDiff: 220 });
270+
logRef.value.acceptParams({ id: id, type: 'php', tail: true });
271271
};
272272
273273
const openExtensions = () => {

frontend/src/views/website/ssl/index.vue

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
{{ $t('commons.button.delete') }}
2323
</el-button>
2424
</template>
25+
<template #rightToolBar>
26+
<TableRefresh @search="search()" />
27+
</template>
2528
<template #main>
2629
<ComplexTable
2730
:data="data"

frontend/src/views/website/website/config/resource/nginx/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div v-loading="loading">
3-
<CodemirrorPro v-model="content" mode="nginx" />
3+
<CodemirrorPro v-model="content" mode="nginx" :heightDiff="400" />
44
<el-button type="primary" @click="submit()" class="mt-2.5">
55
{{ $t('nginx.saveAndReload') }}
66
</el-button>

frontend/src/views/website/website/create/index.vue

+8-4
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ const initData = () => ({
606606
ftpUser: '',
607607
ftpPassword: '',
608608
proxyType: 'tcp',
609-
port: 0,
609+
port: 9000,
610610
proxyProtocol: 'http://',
611611
proxyAddress: '',
612612
runtimeType: 'php',
@@ -808,9 +808,13 @@ const changeRuntime = (runID: number) => {
808808
runtimes.value.forEach((item) => {
809809
if (item.id === runID) {
810810
runtimeResource.value = item.resource;
811-
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
812-
if (runtimePorts.value.length > 0) {
813-
website.value.port = runtimePorts.value[0];
811+
if (runtimeResource.value == 'local') {
812+
website.value.port = 9000;
813+
} else {
814+
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
815+
if (runtimePorts.value.length > 0) {
816+
website.value.port = runtimePorts.value[0];
817+
}
814818
}
815819
}
816820
});

frontend/src/views/website/website/index.vue

+8-9
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@
5151
</div>
5252
</el-select>
5353
<TableSearch @search="search()" v-model:searchName="req.name" />
54-
<div class="!ml-2.5">
55-
<fu-table-column-select
56-
:columns="columns"
57-
trigger="hover"
58-
:title="$t('commons.table.selectColumn')"
59-
popper-class="popper-class"
60-
:only-icon="true"
61-
/>
62-
</div>
54+
<TableRefresh @search="search()" />
55+
<fu-table-column-select
56+
:columns="columns"
57+
trigger="hover"
58+
:title="$t('commons.table.selectColumn')"
59+
popper-class="popper-class"
60+
:only-icon="true"
61+
/>
6362
</template>
6463
<template v-if="!openNginxConfig" #main>
6564
<ComplexTable

frontend/src/views/website/website/nginx/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<Status v-if="activeName === '1'" :status="status" />
3232
<Source v-if="activeName === '2'" />
3333
<NginxPer v-if="activeName === '3'" />
34-
<ContainerLog v-if="activeName === '4'" :container="containerName" />
34+
<ContainerLog v-if="activeName === '4'" :container="containerName" :highlightDiff="350" />
3535
<Module v-if="activeName === '5'" />
3636
</template>
3737
</LayoutContent>

0 commit comments

Comments
 (0)