-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (44 loc) · 1.43 KB
/
main.py
File metadata and controls
55 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import threading
import uvicorn
from processor import AccountProcessor
from logger import log_info
import config
def start_api():
"""启动API服务"""
try:
# 尝试使用 httptools(Windows 上更稳定,避免 h11 协议错误)
import httptools
http_impl = "httptools"
except ImportError:
# 如果 httptools 不可用,使用默认的 h11
http_impl = "auto"
uvicorn.run(
"api:app",
host=config.API_HOST,
port=config.API_PORT,
reload=False,
http=http_impl
)
def start_processor():
"""启动账号处理器"""
processor = AccountProcessor()
processor.process_pending_accounts()
if __name__ == "__main__":
log_info("=" * 60)
log_info("账号处理系统")
log_info("=" * 60)
log_info(f"Codex命令: {config.CODEX_COMMAND}")
log_info(f"Auth目录: {config.CODEX_DIR_NAME}")
log_info(f"日志目录: logs/app.log")
log_info("")
# 在单独的线程中启动API
api_thread = threading.Thread(target=start_api, daemon=True)
api_thread.start()
log_info(f"API服务: http://localhost:{config.API_PORT}")
log_info(f"添加账号: POST http://localhost:{config.API_PORT}/add_account")
log_info(f"查看统计: GET http://localhost:{config.API_PORT}/stats")
log_info("")
log_info("=" * 60)
log_info("")
# 在主线程中运行处理器
start_processor()