Files
ai-balance-monitor/main.py
T

41 lines
1.4 KiB
Python
Raw 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.
"""AI Balance Monitor 入口:python main.py"""
from __future__ import annotations
import logging
import uvicorn
from app import db
from app.api import create_app
from app.config import load_config
from app.providers import list_providers
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger("monitor.main")
def main() -> None:
cfg = load_config()
app = create_app(cfg)
tg = "已配置" if cfg.telegram_bot_token and cfg.telegram_chat_id else "未配置"
with db.get_conn() as conn:
total = conn.execute("SELECT COUNT(*) FROM accounts").fetchone()[0]
enabled = conn.execute("SELECT COUNT(*) FROM accounts WHERE enabled=1").fetchone()[0]
logger.info("========== AI Balance Monitor 启动 ==========")
logger.info("端口 %s | 全局间隔 %ss | 重试 %s | 超时 %ss | 并发 %s", cfg.port, cfg.global_interval_seconds, cfg.retry_count, cfg.timeout_seconds, cfg.max_workers)
logger.info("Telegram 提醒: %s", tg)
logger.info("内置平台: %s", ", ".join(p["name"] for p in list_providers()))
logger.info("账号: %s 个(启用 %s| 数据库: %s", total, enabled, db.DB_PATH)
logger.info("面板地址: http://127.0.0.1:%s", cfg.port)
uvicorn.run(app, host="0.0.0.0", port=cfg.port, log_level="warning")
if __name__ == "__main__":
main()