mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
fix db config
This commit is contained in:
+10
-14
@@ -42,10 +42,6 @@ class SystemConfModel(BaseModel):
|
|||||||
scheduler: int = 0
|
scheduler: int = 0
|
||||||
# 线程池大小
|
# 线程池大小
|
||||||
threadpool: int = 0
|
threadpool: int = 0
|
||||||
# 数据库连接池大小
|
|
||||||
dbpool: int = 0
|
|
||||||
# 数据库连接池溢出数量
|
|
||||||
dbpooloverflow: int = 0
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigModel(BaseModel):
|
class ConfigModel(BaseModel):
|
||||||
@@ -105,6 +101,8 @@ class ConfigModel(BaseModel):
|
|||||||
DB_TYPE: str = "sqlite"
|
DB_TYPE: str = "sqlite"
|
||||||
# 是否在控制台输出 SQL 语句,默认关闭
|
# 是否在控制台输出 SQL 语句,默认关闭
|
||||||
DB_ECHO: bool = False
|
DB_ECHO: bool = False
|
||||||
|
# SQLite 的 busy_timeout 参数,默认为 60 秒
|
||||||
|
DB_TIMEOUT: int = 60
|
||||||
# 数据库连接池类型,QueuePool, NullPool
|
# 数据库连接池类型,QueuePool, NullPool
|
||||||
DB_POOL_TYPE: str = "QueuePool"
|
DB_POOL_TYPE: str = "QueuePool"
|
||||||
# 是否在获取连接时进行预先 ping 操作
|
# 是否在获取连接时进行预先 ping 操作
|
||||||
@@ -113,8 +111,10 @@ class ConfigModel(BaseModel):
|
|||||||
DB_POOL_RECYCLE: int = 300
|
DB_POOL_RECYCLE: int = 300
|
||||||
# 数据库连接池获取连接的超时时间(秒)
|
# 数据库连接池获取连接的超时时间(秒)
|
||||||
DB_POOL_TIMEOUT: int = 30
|
DB_POOL_TIMEOUT: int = 30
|
||||||
# SQLite 的 busy_timeout 参数,默认为 60 秒
|
# SQLite 连接池大小
|
||||||
DB_TIMEOUT: int = 60
|
DB_POOL_SIZE: int = 30
|
||||||
|
# SQLite 连接池溢出数量
|
||||||
|
DB_MAX_OVERFLOW: int = 50
|
||||||
# SQLite 是否启用 WAL 模式,默认开启
|
# SQLite 是否启用 WAL 模式,默认开启
|
||||||
DB_WAL_ENABLE: bool = True
|
DB_WAL_ENABLE: bool = True
|
||||||
# PostgreSQL 主机地址
|
# PostgreSQL 主机地址
|
||||||
@@ -128,9 +128,9 @@ class ConfigModel(BaseModel):
|
|||||||
# PostgreSQL 密码
|
# PostgreSQL 密码
|
||||||
DB_POSTGRESQL_PASSWORD: str = "moviepilot"
|
DB_POSTGRESQL_PASSWORD: str = "moviepilot"
|
||||||
# PostgreSQL 连接池大小
|
# PostgreSQL 连接池大小
|
||||||
DB_POSTGRESQL_POOL_SIZE: int = 20
|
DB_POSTGRESQL_POOL_SIZE: int = 30
|
||||||
# PostgreSQL 连接池溢出数量
|
# PostgreSQL 连接池溢出数量
|
||||||
DB_POSTGRESQL_MAX_OVERFLOW: int = 30
|
DB_POSTGRESQL_MAX_OVERFLOW: int = 50
|
||||||
|
|
||||||
# ==================== 缓存配置 ====================
|
# ==================== 缓存配置 ====================
|
||||||
# 缓存类型,支持 cachetools 和 redis,默认使用 cachetools
|
# 缓存类型,支持 cachetools 和 redis,默认使用 cachetools
|
||||||
@@ -659,9 +659,7 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
|||||||
fanart=512,
|
fanart=512,
|
||||||
meta=(self.META_CACHE_EXPIRE or 24) * 3600,
|
meta=(self.META_CACHE_EXPIRE or 24) * 3600,
|
||||||
scheduler=100,
|
scheduler=100,
|
||||||
threadpool=100,
|
threadpool=100
|
||||||
dbpool=100,
|
|
||||||
dbpooloverflow=50
|
|
||||||
)
|
)
|
||||||
return SystemConfModel(
|
return SystemConfModel(
|
||||||
torrents=100,
|
torrents=100,
|
||||||
@@ -672,9 +670,7 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
|||||||
fanart=128,
|
fanart=128,
|
||||||
meta=(self.META_CACHE_EXPIRE or 2) * 3600,
|
meta=(self.META_CACHE_EXPIRE or 2) * 3600,
|
||||||
scheduler=50,
|
scheduler=50,
|
||||||
threadpool=50,
|
threadpool=50
|
||||||
dbpool=50,
|
|
||||||
dbpooloverflow=20
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
+2
-2
@@ -64,9 +64,9 @@ def _get_sqlite_engine(is_async: bool = False):
|
|||||||
# 当使用 QueuePool 时,添加 QueuePool 特有的参数
|
# 当使用 QueuePool 时,添加 QueuePool 特有的参数
|
||||||
if _pool_class == QueuePool:
|
if _pool_class == QueuePool:
|
||||||
_db_kwargs.update({
|
_db_kwargs.update({
|
||||||
"pool_size": settings.CONF.dbpool,
|
"pool_size": settings.DB_POOL_SIZE,
|
||||||
"pool_timeout": settings.DB_POOL_TIMEOUT,
|
"pool_timeout": settings.DB_POOL_TIMEOUT,
|
||||||
"max_overflow": settings.CONF.dbpooloverflow
|
"max_overflow": settings.DB_MAX_OVERFLOW
|
||||||
})
|
})
|
||||||
|
|
||||||
# 创建数据库引擎
|
# 创建数据库引擎
|
||||||
|
|||||||
Reference in New Issue
Block a user