mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 06:40:35 +01:00
Ajout de la gestion des rôles de modération dans le panneau d'administration. Mise à jour de la logique de configuration pour permettre la sélection de plusieurs rôles. Amélioration de l'interface utilisateur pour la gestion des rôles et des commandes de modération. Ajout de la mise à jour automatique du cache anti-cheat et de nouvelles fonctionnalités pour récupérer et stocker les données anti-cheat.
This commit is contained in:
40
run-web.py
40
run-web.py
@@ -1,6 +1,8 @@
|
||||
import locale
|
||||
import logging
|
||||
import threading
|
||||
import os
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from webapp import webapp
|
||||
from discordbot import bot
|
||||
@@ -23,12 +25,40 @@ def start_twitch_bot():
|
||||
twitchBot.begin()
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Config logs (console + fichier avec rotation)
|
||||
os.makedirs('logs', exist_ok=True)
|
||||
log_formatter = logging.Formatter('%(asctime)s %(levelname)s [%(threadName)s] %(name)s: %(message)s')
|
||||
handlers = []
|
||||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.setFormatter(log_formatter)
|
||||
handlers.append(stream_handler)
|
||||
file_handler = RotatingFileHandler('logs/app.log', maxBytes=5*1024*1024, backupCount=5, encoding='utf-8')
|
||||
file_handler.setFormatter(log_formatter)
|
||||
handlers.append(file_handler)
|
||||
logging.basicConfig(level=logging.INFO, handlers=handlers)
|
||||
|
||||
# Calmer les logs verbeux de certaines libs si besoin
|
||||
logging.getLogger('werkzeug').setLevel(logging.WARNING)
|
||||
logging.getLogger('discord').setLevel(logging.WARNING)
|
||||
|
||||
# Hook exceptions non-capturées (threads inclus)
|
||||
def _log_uncaught(exc_type, exc, tb):
|
||||
logging.exception('Exception non capturée', exc_info=(exc_type, exc, tb))
|
||||
import sys
|
||||
sys.excepthook = _log_uncaught
|
||||
if hasattr(threading, 'excepthook'):
|
||||
def _thread_excepthook(args):
|
||||
logging.exception(f"Exception dans le thread {args.thread.name}", exc_info=(args.exc_type, args.exc_value, args.exc_traceback))
|
||||
threading.excepthook = _thread_excepthook
|
||||
|
||||
locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8')
|
||||
|
||||
jobs = []
|
||||
jobs.append(threading.Thread(target=start_discord_bot))
|
||||
jobs.append(threading.Thread(target=start_server))
|
||||
jobs.append(threading.Thread(target=start_twitch_bot))
|
||||
jobs.append(threading.Thread(target=start_discord_bot, name='discord-bot'))
|
||||
jobs.append(threading.Thread(target=start_server, name='web-server'))
|
||||
jobs.append(threading.Thread(target=start_twitch_bot, name='twitch-bot'))
|
||||
|
||||
for job in jobs: job.start()
|
||||
for job in jobs: job.join()
|
||||
for job in jobs:
|
||||
job.start()
|
||||
for job in jobs:
|
||||
job.join()
|
||||
|
||||
Reference in New Issue
Block a user