Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent/app/dto/request/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type PHPConfigUpdate struct {
Scope string `json:"scope" validate:"required"`
DisableFunctions []string `json:"disableFunctions"`
UploadMaxSize string `json:"uploadMaxSize"`
MaxExecutionTime string `json:"maxExecutionTime"`
}

type PHPFileUpdate struct {
Expand Down
21 changes: 11 additions & 10 deletions agent/app/dto/response/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ type WebsiteNginxConfig struct {
}

type WebsiteHTTPS struct {
Enable bool `json:"enable"`
HttpConfig string `json:"httpConfig"`
SSL model.WebsiteSSL `json:"SSL"`
SSLProtocol []string `json:"SSLProtocol"`
Algorithm string `json:"algorithm"`
Hsts bool `json:"hsts"`
HstsIncludeSubDomains bool `json:"hstsIncludeSubDomains"`
HttpsPorts []int `json:"httpsPorts"`
HttpsPort string `json:"httpsPort"`
Http3 bool `json:"http3"`
Enable bool `json:"enable"`
HttpConfig string `json:"httpConfig"`
SSL model.WebsiteSSL `json:"SSL"`
SSLProtocol []string `json:"SSLProtocol"`
Algorithm string `json:"algorithm"`
Hsts bool `json:"hsts"`
HstsIncludeSubDomains bool `json:"hstsIncludeSubDomains"`
HttpsPorts []int `json:"httpsPorts"`
HttpsPort string `json:"httpsPort"`
Http3 bool `json:"http3"`
}

type WebsiteLog struct {
Expand All @@ -82,6 +82,7 @@ type PHPConfig struct {
Params map[string]string `json:"params"`
DisableFunctions []string `json:"disableFunctions"`
UploadMaxSize string `json:"uploadMaxSize"`
MaxExecutionTime string `json:"maxExecutionTime"`
}

type NginxRewriteRes struct {
Expand Down
13 changes: 13 additions & 0 deletions agent/app/service/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ func (r *RuntimeService) GetPHPConfig(id uint) (*response.PHPConfig, error) {
if uploadMaxSize != "" {
res.UploadMaxSize = uploadMaxSize
}
timeout := phpConfig.Key("max_execution_time").Value()
if timeout != "" {
res.MaxExecutionTime = timeout
}
return res, nil
}

Expand Down Expand Up @@ -912,6 +916,15 @@ func (r *RuntimeService) UpdatePHPConfig(req request.PHPConfigUpdate) (err error
if matched, _ := regexp.MatchString(patternUpload, line); matched {
lines[i] = "upload_max_filesize" + " = " + req.UploadMaxSize
}
case "max_execution_time":
pattern := "^" + regexp.QuoteMeta("max_execution_time") + "\\s*=\\s*.*$"
if matched, _ := regexp.MatchString(pattern, line); matched {
lines[i] = "max_execution_time" + " = " + req.MaxExecutionTime
}
patternInput := "^" + regexp.QuoteMeta("max_input_time") + "\\s*=\\s*.*$"
if matched, _ := regexp.MatchString(patternInput, line); matched {
lines[i] = "max_input_time" + " = " + req.MaxExecutionTime
}
}
}
updatedContent := strings.Join(lines, "\n")
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api/interface/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export namespace Runtime {
params: any;
disableFunctions: string[];
uploadMaxSize: string;
maxExecutionTime: string;
}

export interface PHPConfigUpdate {
Expand All @@ -171,6 +172,7 @@ export namespace Runtime {
disableFunctions?: string[];
scope: string;
uploadMaxSize?: string;
maxExecutionTime?: string;
}

export interface PHPUpdate {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/modules/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const GetPHPConfig = (id: number) => {
};

export const UpdatePHPConfig = (req: Runtime.PHPConfigUpdate) => {
return http.post<any>(`/runtimes/php/config/`, req);
return http.post<any>(`/runtimes/php/config`, req);
};

export const UpdatePHPFile = (req: Runtime.PHPUpdate) => {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/views/website/runtime/php/config/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<el-tab-pane :label="$t('php.uploadMaxSize')" name="2">
<Upload :id="runtime.id" v-if="index == '2'"></Upload>
</el-tab-pane>
<el-tab-pane :label="$t('cronjob.timeout')" name="8">
<Timeout :id="runtime.id" v-if="index == '8'"></Timeout>
</el-tab-pane>
<el-tab-pane :label="$t('website.nginxPer')" name="5">
<Performance :id="runtime.id" v-if="index == '5'"></Performance>
</el-tab-pane>
Expand Down Expand Up @@ -47,6 +50,7 @@ import PHP from './php-fpm/index.vue';
import Performance from './performance/index.vue';
import Container from './container/index.vue';
import FpmStatus from './fpm-status/index.vue';
import Timeout from './timeout/index.vue';

const index = ref('6');
const open = ref(false);
Expand Down
92 changes: 92 additions & 0 deletions frontend/src/views/website/runtime/php/config/timeout/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<template>
<div v-loading="loading">
<el-row>
<el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8" :offset="1">
<el-form :model="form" :rules="rules" ref="phpFormRef">
<el-form-item prop="timeout">
<el-input clearable type="number" v-model.number="form.timeout" maxlength="15">
<template #append>{{ $t('commons.units.second') }}</template>
</el-input>
</el-form-item>
</el-form>
<el-button type="primary" @click="openCreate(phpFormRef)">
{{ $t('commons.button.save') }}
</el-button>
</el-col>
</el-row>
</div>
</template>
<script setup lang="ts">
import { GetPHPConfig, UpdatePHPConfig } from '@/api/modules/runtime';
import { Rules, checkNumberRange } from '@/global/form-rules';
import { computed, onMounted, reactive } from 'vue';
import { ref } from 'vue';
import { FormInstance } from 'element-plus';
import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message';

const props = defineProps({
id: {
type: Number,
default: 0,
},
});
const websiteID = computed(() => {
return props.id;
});
const rules = reactive({
timeout: [Rules.requiredInput, checkNumberRange(0, 999999999)],
});
const phpFormRef = ref();
const loading = ref(false);
const form = ref({
timeout: 0,
});

const search = () => {
loading.value = true;
GetPHPConfig(websiteID.value)
.then((res) => {
form.value.timeout = parseFloat(res.data.maxExecutionTime.replace(/[^\d.]/g, ''));
})
.finally(() => {
loading.value = false;
});
};

const openCreate = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
const action = await ElMessageBox.confirm(
i18n.global.t('database.restartNowHelper'),
i18n.global.t('database.confChange'),
{
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
type: 'info',
},
);
if (action === 'confirm') {
loading.value = true;
submit();
}
});
};

const submit = () => {
loading.value = true;
UpdatePHPConfig({ scope: 'max_execution_time', id: websiteID.value, maxExecutionTime: String(form.value.timeout) })
.then(() => {
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
search();
})
.finally(() => {
loading.value = false;
});
};

onMounted(() => {
search();
});
</script>
Loading