add
This commit is contained in:
0
config/__init__.py
Normal file
0
config/__init__.py
Normal file
25
config/database.py
Normal file
25
config/database.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# MySQL数据库配置
|
||||
DATABASE_CONFIG = {
|
||||
'host': os.getenv('DB_HOST', 'localhost'),
|
||||
'port': int(os.getenv('DB_PORT', 3306)),
|
||||
'user': os.getenv('DB_USER', 'root'),
|
||||
'password': os.getenv('DB_PASSWORD', ''),
|
||||
'database': os.getenv('DB_DATABASE', 'exchange_monitor'),
|
||||
'charset': 'utf8mb4',
|
||||
'pool_size': int(os.getenv('DB_POOL_SIZE', 10)),
|
||||
'max_overflow': int(os.getenv('DB_MAX_OVERFLOW', 20)),
|
||||
'pool_recycle': int(os.getenv('DB_POOL_RECYCLE', 3600))
|
||||
}
|
||||
|
||||
# SQLAlchemy配置
|
||||
SQLALCHEMY_CONFIG = {
|
||||
'echo': os.getenv('SQLALCHEMY_ECHO', 'False').lower() == 'true',
|
||||
'echo_pool': os.getenv('SQLALCHEMY_ECHO_POOL', 'False').lower() == 'true',
|
||||
'pool_pre_ping': True,
|
||||
'pool_recycle': 3600
|
||||
}
|
||||
35
config/settings.py
Normal file
35
config/settings.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Redis配置
|
||||
REDIS_CONFIG = {
|
||||
'host': os.getenv('REDIS_HOST', 'localhost'),
|
||||
'port': int(os.getenv('REDIS_PORT', 6379)),
|
||||
'password': os.getenv('REDIS_PASSWORD', ''),
|
||||
'db': int(os.getenv('REDIS_DB', 0)),
|
||||
'decode_responses': True,
|
||||
'max_connections': 30
|
||||
}
|
||||
|
||||
# 同步配置
|
||||
SYNC_CONFIG = {
|
||||
'interval': int(os.getenv('SYNC_INTERVAL', 60)), # 同步间隔(秒)
|
||||
'recent_days': int(os.getenv('RECENT_DAYS', 3)), # 同步最近几天数据
|
||||
'chunk_size': int(os.getenv('CHUNK_SIZE', 1000)), # 批量处理大小
|
||||
'enable_position_sync': os.getenv('ENABLE_POSITION_SYNC', 'true').lower() == 'true',
|
||||
'enable_order_sync': os.getenv('ENABLE_ORDER_SYNC', 'true').lower() == 'true',
|
||||
'enable_account_sync': os.getenv('ENABLE_ACCOUNT_SYNC', 'true').lower() == 'true'
|
||||
}
|
||||
|
||||
# 日志配置
|
||||
LOG_CONFIG = {
|
||||
'level': os.getenv('LOG_LEVEL', 'INFO'),
|
||||
'rotation': os.getenv('LOG_ROTATION', '10 MB'),
|
||||
'retention': os.getenv('LOG_RETENTION', '7 days'),
|
||||
'format': '{time:YYYY-MM-DD HH:mm:ss} | {level} | {name}:{function}:{line} - {message}'
|
||||
}
|
||||
|
||||
# 计算机名配置(用于过滤账号)
|
||||
COMPUTER_NAME = os.getenv('COMPUTER_NAME', 'lz_c01')
|
||||
Reference in New Issue
Block a user