diff --git a/apps/devops/app/backend/infra/rabbitmq/async_client.py b/apps/devops/app/backend/infra/rabbitmq/async_client.py index a48fc58..39e9f28 100644 --- a/apps/devops/app/backend/infra/rabbitmq/async_client.py +++ b/apps/devops/app/backend/infra/rabbitmq/async_client.py @@ -37,8 +37,10 @@ class AsyncMQClient: name=self.exchange_name, type="direct", auto_delete=False ) + # Connect to existing named queue instead of creating anonymous queue + # channel_name already contains the full queue name from environment variable self.queue = await self.channel.declare_queue( - name=None, exclusive=True, auto_delete=True, durable=False + name=self.channel_name, exclusive=False, auto_delete=False, durable=True ) await self.queue.bind( exchange=self.exchange, routing_key=self.routing_key diff --git a/apps/devops/app/main.py b/apps/devops/app/main.py index 559d7ed..1bfc3d4 100644 --- a/apps/devops/app/main.py +++ b/apps/devops/app/main.py @@ -13,4 +13,5 @@ async def root(): if __name__ == "__main__": import uvicorn + print("Starting FastAPI server...") uvicorn.run("main:app", host=site_settings.SERVER_HOST, port=site_settings.SERVER_PORT, reload=True) \ No newline at end of file diff --git a/apps/devops/app/providers/common.py b/apps/devops/app/providers/common.py index 64a9a44..656bcc3 100644 --- a/apps/devops/app/providers/common.py +++ b/apps/devops/app/providers/common.py @@ -11,13 +11,13 @@ def register(app): # This hook ensures that a connection is opened to handle any queries # generated by the request. @app.on_event("startup") - def startup(): + async def startup(): pass # This hook ensures that the connection is closed when we've finished # processing the request. @app.on_event("shutdown") - def shutdown(): + async def shutdown(): pass diff --git a/apps/devops/app/providers/message_queue.py b/apps/devops/app/providers/message_queue.py index 978e232..b2d87cb 100644 --- a/apps/devops/app/providers/message_queue.py +++ b/apps/devops/app/providers/message_queue.py @@ -1,4 +1,5 @@ import asyncio +import os from app.backend.infra.rabbitmq.async_subscriber import AsyncMQSubscriber from app.backend.services.deployment_status_update_service import DeploymentStatusUpdateService @@ -15,7 +16,9 @@ def register(app): try: # Initialize services during startup to avoid blocking app initialization print("🔧 Initializing services...") - app.deployment_heartbeat_subscriber = AsyncMQSubscriber("devops_reconcile_heartbeat") + output_queue_name = os.getenv("RABBITMQ_OUTPUT_QUEUE_NAME", "freeleaps.devops.reconciler.output") + print(f"Using output queue: {output_queue_name}") + app.deployment_heartbeat_subscriber = AsyncMQSubscriber(output_queue_name) app.deployment_status_service = DeploymentStatusUpdateService() print("✅ Services initialized")