fix: Fix redis configuration modification issues (#9848)

Refs #9832
This commit is contained in:
ssongliu 2025-08-05 11:26:59 +08:00 committed by GitHub
parent 12b9356c17
commit 7c49f6c79b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 16 additions and 10 deletions

View file

@ -4,14 +4,14 @@ import "time"
// common
type DBConfUpdateByFile struct {
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis mysql-cluster postgresql-cluster"`
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis mysql-cluster postgresql-cluster redis-cluster"`
Database string `json:"database" validate:"required"`
File string `json:"file"`
}
type ChangeDBInfo struct {
ID uint `json:"id"`
From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql mysql-cluster postgresql-cluster"`
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql mysql-cluster postgresql-cluster redis-cluster"`
Database string `json:"database" validate:"required"`
Value string `json:"value" validate:"required"`
}

View file

@ -672,7 +672,7 @@ func (a *AppInstallService) GetDefaultConfigByKey(key, name string) (string, err
if key == constant.AppMysql || key == constant.AppMariaDB || key == constant.AppMysqlCluster {
filePath = path.Join(filePath, "my.cnf")
}
if key == constant.AppRedis {
if key == constant.AppRedis || key == constant.AppRedisCluster {
filePath = path.Join(filePath, "redis.conf")
}
if key == constant.AppOpenresty {

View file

@ -74,11 +74,11 @@ func (u *DBCommonService) UpdateConfByFile(req dto.DBConfUpdateByFile) error {
}
path := ""
switch req.Type {
case constant.AppMariaDB, constant.AppMysql:
case constant.AppMariaDB, constant.AppMysql, constant.AppMysqlCluster:
path = fmt.Sprintf("%s/%s/%s/conf/my.cnf", global.Dir.AppInstallDir, req.Type, app.Name)
case constant.AppPostgresql:
case constant.AppPostgresql, constant.AppPostgresqlCluster:
path = fmt.Sprintf("%s/%s/%s/data/postgresql.conf", global.Dir.AppInstallDir, req.Type, app.Name)
case constant.AppRedis:
case constant.AppRedis, constant.AppRedisCluster:
path = fmt.Sprintf("%s/%s/%s/conf/redis.conf", global.Dir.AppInstallDir, req.Type, app.Name)
}
file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0640)

View file

@ -53,7 +53,7 @@ func (u *RedisService) UpdateConf(req dto.RedisConfUpdate) error {
if err := confSet(redisInfo.Name, req.DBType, "", confs); err != nil {
return err
}
if _, err := compose.Restart(fmt.Sprintf("%s/redis/%s/docker-compose.yml", global.Dir.AppInstallDir, redisInfo.Name)); err != nil {
if _, err := compose.Restart(fmt.Sprintf("%s/%s/%s/docker-compose.yml", global.Dir.AppInstallDir, req.DBType, redisInfo.Name)); err != nil {
return err
}

View file

@ -221,6 +221,7 @@ export namespace Database {
// redis
export interface RedisConfUpdate {
dbType: string;
database: string;
timeout: string;
maxclients: string;

View file

@ -28,7 +28,7 @@
<template #main>
<div v-if="activeName === 'conf'">
<CodemirrorPro v-model="postgresqlConf"></CodemirrorPro>
<CodemirrorPro :heightDiff="320" v-model="postgresqlConf"></CodemirrorPro>
<el-button type="primary" class="mt-5" @click="onSaveConf">
{{ $t('commons.button.save') }}
</el-button>

View file

@ -39,7 +39,11 @@
</template>
<template #main>
<div v-if="activeName === 'conf'">
<CodemirrorPro v-model="redisConf" :placeholder="$t('commons.msg.noneData')"></CodemirrorPro>
<CodemirrorPro
:heightDiff="340"
v-model="redisConf"
:placeholder="$t('commons.msg.noneData')"
></CodemirrorPro>
<el-button class="mt-5" @click="getDefaultConfig()">
{{ $t('app.defaultConfig') }}
</el-button>
@ -232,6 +236,7 @@ const onChangePort = async (formEl: FormInstance | undefined) => {
return;
}
let params = {
type: dbType.value,
key: dbType.value,
name: form.name,
port: form.port,
@ -262,7 +267,7 @@ const onSubmitForm = async (formEl: FormInstance | undefined) => {
};
const submitForm = async () => {
let param = {
dbType: 'redis',
dbType: dbType.value,
database: database.value,
timeout: form.timeout + '',
maxclients: form.maxclients + '',