Skip to content

Commit

Permalink
Merge pull request #3004 from InfinityPacer/feature/module
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Nov 4, 2024
2 parents 9e08b91 + 8afaa68 commit 656cc1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class Config:
DB_POOL_RECYCLE: int = 1800
# 数据库连接池获取连接的超时时间(秒),默认 60 秒
DB_POOL_TIMEOUT: int = 60
# 数据库连接池最大溢出连接数,默认 10
DB_MAX_OVERFLOW: int = 10
# 数据库连接池最大溢出连接数,默认 500
DB_MAX_OVERFLOW: int = 500
# SQLite 的 busy_timeout 参数,默认为 60 秒
DB_TIMEOUT: int = 60
# 配置文件目录
Expand Down Expand Up @@ -360,15 +360,19 @@ def update_setting(self, key: str, value: Any) -> Tuple[bool, str]:

try:
field = self.__fields__[key]
original_value = getattr(self, key)
if field.name == "API_TOKEN":
converted_value, needs_update = self.validate_api_token(value, getattr(self, key))
converted_value, needs_update = self.validate_api_token(value, original_value)
else:
converted_value, needs_update = self.generic_type_converter(value, getattr(self, key), field.type_,
converted_value, needs_update = self.generic_type_converter(value, original_value, field.type_,
field.default, key)
# 如果没有抛出异常,则统一使用 converted_value 进行更新
if needs_update or str(value) != str(converted_value):
setattr(self, key, converted_value)
return self.update_env_config(field, value, converted_value)
success, message = self.update_env_config(field, original_value, converted_value)
# 仅成功更新配置时,才更新内存
if success:
setattr(self, key, converted_value)
return success, message
return True, ""
except Exception as e:
return False, str(e)
Expand Down
2 changes: 1 addition & 1 deletion config/app.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LOG_LEVEL=INFO
# 数据库连接池的大小,可适当降低如20-50以减少I/O压力
DB_POOL_SIZE=100
# 数据库连接池最大溢出连接数,可适当降低如0以减少I/O压力
DB_MAX_OVERFLOW=10
DB_MAX_OVERFLOW=500
# SQLite 的 busy_timeout 参数,可适当增加如180以减少锁定错误
DB_TIMEOUT=60
# 【*】超级管理员,设置后一但重启将固化到数据库中,修改将无效(初始化超级管理员密码仅会生成一次,请在日志中查看并自行登录系统修改)
Expand Down

0 comments on commit 656cc1f

Please sign in to comment.