VisionApp/vision.py
Mathis e22a98a4a3
All checks were successful
ci / ci (push) Successful in 44s
ci / ci (pull_request) Successful in 43s
ci: align deployment on Kuby (Docker + rsync + SSH key + healthcheck + rollback)
- Add HTTP /health endpoint (aiohttp) for Docker healthcheck + post-deploy check
- Dockerfile HEALTHCHECK hits /health; docker-compose exposes 1890, container vision-bot
- scripts/deploy_runner.sh runs on .117 (docker compose build/restart)
- .forgejo/workflows/deploy.yml: single job on omhk-deploy runner (clone, syntax test,
  rsync, deploy, health check, auto-rollback) like Kuby
- .forgejo/workflows/ci.yml: single job (ruff + pytest) on dev/PR
2026-09-19 16:04:59 +02:00

41 lines
1 KiB
Python

import asyncio
import logging
import sys
import config
from bot import VisionBot
from health import start_health_server
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s | %(levelname)-8s | %(name)s — %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler(config.LOGS_DIR / "vision.log", encoding="utf-8"),
],
)
logger = logging.getLogger("vision")
async def main():
if not config.DISCORD_TOKEN:
logger.critical("DISCORD_TOKEN manquant dans .env")
sys.exit(1)
instance = "DEV" if config.DEV else "PROD"
logger.info(f"Lancement de Vision Studio [{instance}]...")
await start_health_server(config.HEALTH_PORT)
bot = VisionBot()
try:
await bot.start(config.DISCORD_TOKEN)
except KeyboardInterrupt:
logger.info("Arrêt demandé")
except Exception as e:
logger.critical(f"Erreur fatale : {e}", exc_info=True)
if __name__ == "__main__":
asyncio.run(main())