mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-10 17:13:30 +08:00
fix: 端口修改增加存在校验
This commit is contained in:
parent
fc206deddf
commit
d7ab5ff1b7
4 changed files with 35 additions and 5 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
|
||||
|
@ -269,6 +270,9 @@ func (a AppInstallService) GetUpdateVersions(installId uint) ([]dto.AppVersion,
|
|||
}
|
||||
|
||||
func (a AppInstallService) ChangeAppPort(req request.PortUpdate) error {
|
||||
if common.ScanPort(int(req.Port)) {
|
||||
return buserr.WithDetail(constant.ErrPortInUsed, req.Port, nil)
|
||||
}
|
||||
return updateInstallInfoInDB(req.Key, "", "port", true, strconv.FormatInt(req.Port, 10))
|
||||
}
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ func updateMyCnf(oldFiles []string, group string, param string, value interface{
|
|||
newFiles = append(newFiles, line)
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, param) || strings.HasPrefix(line, "# "+param) {
|
||||
if strings.HasPrefix(line, param+"=") || strings.HasPrefix(line, "# "+param+"=") {
|
||||
newFiles = append(newFiles, fmt.Sprintf("%s=%v", param, value))
|
||||
hasKey = true
|
||||
continue
|
||||
|
|
|
@ -6,9 +6,11 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/encrypt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -62,6 +64,10 @@ func (u *SettingService) Update(key, value string) error {
|
|||
}
|
||||
|
||||
func (u *SettingService) UpdatePort(port uint) error {
|
||||
if common.ScanPort(int(port)) {
|
||||
return buserr.WithDetail(constant.ErrPortInUsed, port, nil)
|
||||
}
|
||||
|
||||
if err := settingRepo.Update("ServerPort", strconv.Itoa(int(port))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div v-show="onSetting" v-loading="loading">
|
||||
<LayoutContent :title="'MySQL ' + $t('database.setting')" :reload="true">
|
||||
<template #buttons>
|
||||
<el-button type="primary" :plain="activeName !== 'conf'" @click="activeName = 'conf'">
|
||||
<el-button type="primary" :plain="activeName !== 'conf'" @click="jumpToConf">
|
||||
{{ $t('database.confChange') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
|
@ -35,7 +35,7 @@
|
|||
<el-button
|
||||
type="primary"
|
||||
:disabled="mysqlStatus !== 'Running'"
|
||||
@click="activeName = 'slowLog'"
|
||||
@click="jumpToSlowlog"
|
||||
:plain="activeName !== 'slowLog'"
|
||||
>
|
||||
{{ $t('database.slowLog') }}
|
||||
|
@ -94,7 +94,12 @@
|
|||
</el-form>
|
||||
</div>
|
||||
<ContainerLog v-show="activeName === 'log'" ref="dialogContainerLogRef" />
|
||||
<SlowLog @loading="changeLoading" v-show="activeName === 'slowLog'" ref="slowLogRef" />
|
||||
<SlowLog
|
||||
@loading="changeLoading"
|
||||
@refresh="loadBaseInfo"
|
||||
v-show="activeName === 'slowLog'"
|
||||
ref="slowLogRef"
|
||||
/>
|
||||
</template>
|
||||
</LayoutContent>
|
||||
|
||||
|
@ -125,6 +130,7 @@ import { MsgSuccess } from '@/utils/message';
|
|||
|
||||
const loading = ref(false);
|
||||
|
||||
const baseDir = ref();
|
||||
const extensions = [javascript(), oneDark];
|
||||
const activeName = ref('conf');
|
||||
|
||||
|
@ -172,6 +178,17 @@ const onClose = (): void => {
|
|||
onSetting.value = false;
|
||||
};
|
||||
|
||||
const jumpToConf = async () => {
|
||||
activeName.value = 'conf';
|
||||
const pathRes = await loadBaseDir();
|
||||
loadMysqlConf(`${pathRes.data}/apps/mysql/${mysqlName.value}/conf/my.cnf`);
|
||||
};
|
||||
|
||||
const jumpToSlowlog = async () => {
|
||||
activeName.value = 'slowLog';
|
||||
loadSlowLogs();
|
||||
};
|
||||
|
||||
const onSubmitChangePort = async () => {
|
||||
let params = {
|
||||
key: 'mysql',
|
||||
|
@ -255,6 +272,7 @@ const loadBaseInfo = async () => {
|
|||
baseInfo.port = res.data?.port;
|
||||
baseInfo.containerID = res.data?.containerName;
|
||||
const pathRes = await loadBaseDir();
|
||||
baseDir.value = pathRes.data;
|
||||
loadMysqlConf(`${pathRes.data}/apps/mysql/${mysqlName.value}/conf/my.cnf`);
|
||||
loadContainerLog(baseInfo.containerID);
|
||||
};
|
||||
|
@ -274,7 +292,9 @@ const loadVariables = async () => {
|
|||
};
|
||||
|
||||
const loadSlowLogs = async () => {
|
||||
await Promise.all([loadBaseInfo(), loadVariables()]);
|
||||
const res = await loadMysqlVariables();
|
||||
variables.value = res.data;
|
||||
|
||||
let param = {
|
||||
mysqlName: mysqlName.value,
|
||||
variables: variables.value,
|
||||
|
|
Loading…
Reference in a new issue