mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
refactor(bot): bot utilities into separate modules
Moved logging, signal handling, and uptime calculation logic from bot.py into dedicated utils modules for better organization and reusability. Updated imports and usage in bot.py and utils/__init__.py accordingly.
This commit is contained in:
13
utils/signal.py
Normal file
13
utils/signal.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import asyncio
|
||||
import signal
|
||||
|
||||
|
||||
def setup_signal_handlers(bot):
|
||||
def signal_handler(signum, frame):
|
||||
bot.logger.info("Shutdown requested. Closing bot...")
|
||||
if bot.loop and not bot.loop.is_closed():
|
||||
asyncio.create_task(bot.close())
|
||||
bot.loop.call_soon_threadsafe(bot.loop.stop)
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
Reference in New Issue
Block a user