File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 11import threading
2+ import asyncio
23from bot .bot import bot
34from web .app import app
45from shared .config import DISCORD_TOKEN , ENABLE_LOGGING , BOT_STATUS , BOT_NAME
78import time
89
910
11+ async def start_bot ():
12+ retry_count = 0
13+ max_retries = 5
14+
15+ while retry_count < max_retries :
16+ try :
17+ await bot .start (DISCORD_TOKEN )
18+ except aiohttp .client_exceptions .ClientConnectorError as e :
19+ print (f"Connection error: { e } . Retrying in 10 seconds..." )
20+ retry_count += 1
21+ await asyncio .sleep (10 )
22+ except Exception as e :
23+ print (f"Unexpected error: { e } " )
24+ break
25+
1026def start_prometheus_server ():
1127 # Start a Prometheus HTTP server on port 8000
1228 start_http_server (8000 , addr = '0.0.0.0' )
@@ -46,4 +62,4 @@ async def on_disconnect():
4662 bot .load_extension ('bot.news_feed' )
4763 # bot.load_extension('bot.moderation') Turning off because it's not working
4864 start_prometheus_server ()
49- bot .run (DISCORD_TOKEN )
65+ asyncio .run (start_bot () )
You can’t perform that action at this time.
0 commit comments