Skip to content

Commit

Permalink
feat(engine): Add health check endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
topher-lo committed Mar 19, 2024
1 parent 5ed4ae2 commit d4863f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aws/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
build_args={"API_MODULE": "tracecat.api.app:app"},
),
health_check=ecs.HealthCheck(
command=["CMD-SHELL", "curl -f http://localhost:8000"],
command=["CMD-SHELL", "curl -f http://localhost:8000/health"],
interval=Duration.seconds(120),
retries=5,
start_period=Duration.seconds(60),
Expand Down Expand Up @@ -167,7 +167,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
build_args={"API_MODULE": "tracecat.runner.app:app", "PORT": "8001"},
),
health_check=ecs.HealthCheck(
command=["CMD-SHELL", "curl -f http://localhost:8001"],
command=["CMD-SHELL", "curl -f http://localhost:8001/health"],
interval=Duration.seconds(120),
retries=5,
start_period=Duration.seconds(60),
Expand Down
5 changes: 5 additions & 0 deletions tracecat/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def root() -> dict[str, str]:
return {"message": "Hello world. I am the API."}


@app.get("/health")
def check_health() -> dict[str, str]:
return {"message": "Hello world. I am the API. This is the health endpoint."}


### Workflows


Expand Down
7 changes: 6 additions & 1 deletion tracecat/runner/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ async def valid_workflow(workflow_id: str) -> str:
# Endpoints
@app.get("/")
def root() -> dict[str, str]:
return {"message": "Hello. I am a runner."}
return {"message": "Hello. I am the runner."}


@app.get("/health")
def check_health() -> dict[str, str]:
return {"message": "Hello world. I am the runner. This is the health endpoint."}


class StartWorkflowResponse(BaseModel):
Expand Down

0 comments on commit d4863f9

Please sign in to comment.