mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-14 20:20:38 +01:00
Améliore le healthcheck Docker pour détecter les erreurs en temps réel
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from twitchAPI.twitch import Twitch
|
||||
@@ -36,14 +37,24 @@ async def _notifyAlert(alert : LiveAlert, stream : Stream):
|
||||
|
||||
async def _sendMessage(channel : int, message : str) :
|
||||
logger.info(f'Envoi de notification : {message}')
|
||||
await bot.get_channel(channel).send(message)
|
||||
logger.info(f'Notification envoyé')
|
||||
try:
|
||||
await asyncio.wait_for(bot.get_channel(channel).send(message), timeout=30.0)
|
||||
logger.info(f'Notification envoyée')
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f'Timeout lors de l\'envoi de notification live alert')
|
||||
except Exception as e:
|
||||
logger.error(f'Erreur lors de l\'envoi de notification live alert : {e}')
|
||||
|
||||
async def _retreiveStreams(twitch: Twitch, alerts : list[LiveAlert]) -> list[Stream] :
|
||||
streams : list[Stream] = []
|
||||
logger.info(f'Recherche de streams pour : {alerts}')
|
||||
async for stream in twitch.get_streams(user_login = [alert.login for alert in alerts]):
|
||||
streams.append(stream)
|
||||
logger.info(f'Ces streams sont en ligne : {streams}')
|
||||
try:
|
||||
async for stream in asyncio.wait_for(twitch.get_streams(user_login = [alert.login for alert in alerts]), timeout=30.0):
|
||||
streams.append(stream)
|
||||
logger.info(f'Ces streams sont en ligne : {streams}')
|
||||
except asyncio.TimeoutError:
|
||||
logger.error('Timeout lors de la récupération des streams Twitch')
|
||||
except Exception as e:
|
||||
logger.error(f'Erreur lors de la récupération des streams Twitch : {e}')
|
||||
return streams
|
||||
|
||||
|
||||
Reference in New Issue
Block a user