Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
from app.database.weaviate.client import get_weaviate_client
from integrations.discord.bot import DiscordBot
from discord.ext import commands

# DevRel commands are now loaded dynamically (commented out below)
# from integrations.discord.cogs import DevRelCommands

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
format='%(asctime)s - %(name)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s'
)
logger = logging.getLogger(__name__)

Expand All @@ -35,6 +36,7 @@ def __init__(self):
self.queue_manager = AsyncQueueManager()
self.agent_coordinator = AgentCoordinator(self.queue_manager)
self.discord_bot = DiscordBot(self.queue_manager)
self.discord_task = None

async def start_background_tasks(self):
"""Starts the Discord bot and queue workers in the background."""
Expand All @@ -51,9 +53,10 @@ async def start_background_tasks(self):
except (ImportError, commands.ExtensionError) as e:
logger.error("Failed to load Discord cog extension: %s", e)

# Start the bot as a background task.
asyncio.create_task(
self.discord_bot.start(settings.discord_bot_token)
# Start the bot as a background task and store the reference
self.discord_task = asyncio.create_task(
self.discord_bot.start(settings.discord_bot_token),
name="discord_bot"
)
logger.info("Background tasks started successfully!")
except Exception as e:
Expand Down