Skip to content

Commit

Permalink
[#145] Try to fix health check for rabbitmq, assistant, & eppo
Browse files Browse the repository at this point in the history
  • Loading branch information
wayangalihpratama committed Jan 2, 2025
1 parent c7e7e29 commit 1918a4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ async def consumer():
main()

# Start the HTTP server in a separate thread
server_thread = threading.Thread(target=run, kwargs={"port": 9001})
server_thread = threading.Thread(target=run, kwargs={"port": 5001})
server_thread.start()

asyncio.run(consumer())
21 changes: 10 additions & 11 deletions backend/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ async def consume_task():
app.include_router(static_routes.router, tags=["static file"])


def check_rabbitmq():
async def check_rabbitmq():
try:
response = requests.get(
f'http://{os.getenv("RABBITMQ_HOST")}:15692/metrics'
)
return response.status_code == 200
except requests.exceptions.RequestException as e:
print(f"RabbitMQ check failed: {e}")
await rabbitmq_client.connect(max_retries=1)
await rabbitmq_client.disconnect()
return True
except Exception as e:
logger.error(f"RabbitMQ health check failed: {e}")
return False


Expand Down Expand Up @@ -122,13 +121,13 @@ def check_service(service_name: str, port: int):


@app.get("/health-check", tags=["dev"])
def health_check(session: Session = Depends(get_session)):
async def health_check(session: Session = Depends(get_session)):
services = {
"rabbitmq": check_rabbitmq(),
"rabbitmq": await check_rabbitmq(),
"chromadb": check_chromadb(),
"database": check_database(session=session),
"assistant": check_service("assistant", 9001),
"eppo-librarian": check_service("eppo-librarian", 9002),
"assistant": check_service("assistant", 5001),
"eppo-librarian": check_service("eppo-librarian", 5002),
"backend": True,
}
if all(services.values()):
Expand Down
2 changes: 1 addition & 1 deletion eppo-librarian/eppo-librarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def add_chunks_to_chromadb(
logging.basicConfig(level=logging.INFO)

# Start the HTTP server in a separate thread
server_thread = threading.Thread(target=run, kwargs={"port": 9002})
server_thread = threading.Thread(target=run, kwargs={"port": 5002})
server_thread.start()

# download the NLTK sentence splitter
Expand Down

0 comments on commit 1918a4b

Please sign in to comment.