2026-09-19 12:11:06 +02:00
|
|
|
import asyncio
|
|
|
|
|
import logging
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import config
|
|
|
|
|
from bot import VisionBot
|
2026-09-19 16:04:59 +02:00
|
|
|
from health import start_health_server
|
2026-09-19 12:11:06 +02:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2026-09-19 12:31:30 +02:00
|
|
|
instance = "DEV" if config.DEV else "PROD"
|
|
|
|
|
logger.info(f"Lancement de Vision Studio [{instance}]...")
|
2026-09-19 12:11:06 +02:00
|
|
|
|
2026-09-25 19:59:23 +02:00
|
|
|
if not config.DEV:
|
|
|
|
|
await start_health_server(config.HEALTH_PORT)
|
2026-09-19 16:04:59 +02:00
|
|
|
|
|
|
|
|
bot = VisionBot()
|
2026-09-19 12:11:06 +02:00
|
|
|
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())
|