Files
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

47 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Net-Games 全局配置
import os
# 服务器配置
HOST = os.getenv('NET_GAMES_HOST', '0.0.0.0')
PORT = int(os.getenv('NET_GAMES_PORT', 8900))
DEBUG = os.getenv('NET_GAMES_DEBUG', 'true').lower() == 'true'
# 数据库配置
DATABASE_URL = os.getenv('DATABASE_URL', 'sqlite:///./netgames.db')
# Redis配置 (用于多实例部署,可选)
REDIS_URL = os.getenv('REDIS_URL', None)
# Socket.IO 配置
SOCKET_IO_CONFIG = {
'cors_allowed_origins': '*',
'cors_credentials': True, # 允许携带凭证(cookies)
'async_mode': 'threading',
'ping_timeout': 60,
'ping_interval': 25,
'always_connect': True, # 确保总是可以连接,即使握手失败
'max_http_buffer_size': 1e8, # 增大缓冲区
}
# AI 配置
DEEPSEEK_API_KEY = os.getenv('DEEPSEEK_API_KEY', '')
DEEPSEEK_API_URL = os.getenv('DEEPSEEK_API_URL', 'https://api.deepseek.com/v1/chat/completions')
DEEPSEEK_MODEL = os.getenv('DEEPSEEK_MODEL', 'deepseek-chat')
# AI 调用限制
AI_TIMEOUT_SECONDS = 30
AI_MAX_TOKENS = 2000
# 房间配置
ROOM_MAX_PLAYERS = {
'doudizhu': 3,
'chinese_chess': 2,
}
ROOM_CODE_LENGTH = 6
ROOM_INACTIVE_TIMEOUT_MINUTES = 30
# 日志配置
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'