mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
14 lines
420 B
Python
14 lines
420 B
Python
|
|
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)
|