From b71db62e1160457a0823794da10f5bb257e2ec25 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Tue, 15 Oct 2024 12:46:58 +0100 Subject: [PATCH 1/2] add health endpoint --- autogpt_platform/backend/backend/server/rest_api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/server/rest_api.py index 4d01a935899a..e1aa8c3118d5 100644 --- a/autogpt_platform/backend/backend/server/rest_api.py +++ b/autogpt_platform/backend/backend/server/rest_api.py @@ -78,6 +78,14 @@ def run_service(self): allow_headers=["*"], # Allows all headers ) + health_router = APIRouter() + health_router.add_api_route( + path="/health", + endpoint=self.health_check, + methods=["GET"], + tags=["health"], + ) + # Define the API routes api_router = APIRouter(prefix="/api") api_router.dependencies.append(Depends(auth_middleware)) @@ -640,6 +648,9 @@ def send_execution_update(self, execution_result_dict: dict[Any, Any]): execution_result = execution_db.ExecutionResult(**execution_result_dict) self.event_queue.put(execution_result) + async def health_check(self): + return {"status": "healthy"} + @classmethod def update_configuration( cls, From 78d0a84be320667902d696cf871223c6b5780117 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Wed, 16 Oct 2024 15:53:19 +0100 Subject: [PATCH 2/2] fix linting --- autogpt_platform/backend/backend/server/rest_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/server/rest_api.py index f00e8b3ddbd8..6860f3f60fee 100644 --- a/autogpt_platform/backend/backend/server/rest_api.py +++ b/autogpt_platform/backend/backend/server/rest_api.py @@ -78,7 +78,7 @@ def run_service(self): health_router = APIRouter() health_router.add_api_route( path="/health", - endpoint=self.health_check, + endpoint=self.health, methods=["GET"], tags=["health"], ) @@ -640,7 +640,7 @@ def get_execution_schedules( execution_scheduler = self.execution_scheduler_client return execution_scheduler.get_execution_schedules(graph_id, user_id) - async def health_check(self): + async def health(self): return {"status": "healthy"} @classmethod