feat: enhance message consumer startup and shutdown logging in message_queue.py
Added print statements to log the status of message consumers during startup and shutdown processes, improving traceability and debugging capabilities. Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
parent
113bc2bc75
commit
9283e52e48
@ -10,21 +10,27 @@ def register(app):
|
|||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def start_message_consumers():
|
async def start_message_consumers():
|
||||||
|
print("Starting message consumers")
|
||||||
# Register the heartbeat processor
|
# Register the heartbeat processor
|
||||||
await app.deployment_heartbeat_subscriber.register_consumer(
|
await app.deployment_heartbeat_subscriber.register_consumer(
|
||||||
registry_key="deployment_heartbeat_processor",
|
registry_key="deployment_heartbeat_processor",
|
||||||
callback_method=app.deployment_status_service.process_heartbeat_message,
|
callback_method=app.deployment_status_service.process_heartbeat_message,
|
||||||
args={}
|
args={}
|
||||||
)
|
)
|
||||||
|
print("Registered deployment heartbeat processor")
|
||||||
|
|
||||||
# Start the subscriber
|
# Start the subscriber
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
await loop.create_task(
|
await loop.create_task(
|
||||||
app.deployment_heartbeat_subscriber.subscribe(max_retries=5, event_loop=loop)
|
app.deployment_heartbeat_subscriber.subscribe(max_retries=5, event_loop=loop)
|
||||||
)
|
)
|
||||||
|
print("Started deployment heartbeat subscriber")
|
||||||
|
|
||||||
@app.on_event("shutdown")
|
@app.on_event("shutdown")
|
||||||
async def stop_message_consumers():
|
async def stop_message_consumers():
|
||||||
# Clear consumers and close connection
|
# Clear consumers and close connection
|
||||||
|
print("Stopping message consumers")
|
||||||
await app.deployment_heartbeat_subscriber.clear_all_consumers()
|
await app.deployment_heartbeat_subscriber.clear_all_consumers()
|
||||||
|
print("Cleared all consumers")
|
||||||
await app.deployment_heartbeat_subscriber.close()
|
await app.deployment_heartbeat_subscriber.close()
|
||||||
|
print("Closed deployment heartbeat subscriber")
|
||||||
Loading…
Reference in New Issue
Block a user