Skip to content

Commit 89fee52

Browse files
feat: add /health for agent and simunet.
1 parent fda28de commit 89fee52

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

.github/workflows/release-agent.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ jobs:
6464
**Docker:**
6565
```bash
6666
# Pull the image
67-
docker pull ghcr.io/${{ github.repository }}/netdriver-agent:${{ steps.version.outputs.version }}
67+
docker pull ghcr.io/opensecflow/netdriver-agent:${{ steps.version.outputs.version }}
6868
6969
# Run the agent
7070
docker run -d -p 8000:8000 \
7171
-v $(pwd)/config:/app/config \
7272
-v $(pwd)/logs:/app/logs \
73-
ghcr.io/${{ github.repository }}/netdriver-agent:${{ steps.version.outputs.version }}
73+
ghcr.io/opensecflow/netdriver-agent:${{ steps.version.outputs.version }}
7474
```
7575
7676
**Available tags:** `${{ steps.version.outputs.version }}`, `latest`

.github/workflows/release-simunet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ jobs:
6464
**Docker:**
6565
```bash
6666
# Pull the image
67-
docker pull ghcr.io/${{ github.repository }}/netdriver-simunet:${{ steps.version.outputs.version }}
67+
docker pull ghcr.io/opensecflow/netdriver-simunet:${{ steps.version.outputs.version }}
6868
6969
# Run with host network mode
7070
docker run -d --network host \
7171
-v $(pwd)/config:/app/config \
7272
-v $(pwd)/logs:/app/logs \
73-
ghcr.io/${{ github.repository }}/netdriver-simunet:${{ steps.version.outputs.version }}
73+
ghcr.io/opensecflow/netdriver-simunet:${{ steps.version.outputs.version }}
7474
```
7575
7676
**Available tags:** `${{ steps.version.outputs.version }}`, `latest`

bases/netdriver/agent/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ async def root() -> dict:
7070
}
7171

7272

73+
@app.get("/health")
74+
async def health() -> dict:
75+
""" health check endpoint for docker """
76+
return {
77+
"status": "healthy",
78+
"service": "netdriver-agent"
79+
}
80+
81+
7382
def start():
7483
"""Start the agent server with optional configuration file parameter."""
7584
parser = argparse.ArgumentParser(description="NetDriver Agent Server")

bases/netdriver/simunet/main.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ async def on_shutdown() -> None:
5555
app.add_event_handler("shutdown", on_shutdown)
5656

5757

58+
@app.get("/")
59+
async def root() -> dict:
60+
""" root endpoint """
61+
return {
62+
"message": "Welcome to the NetDriver SimuNet",
63+
}
64+
65+
66+
@app.get("/health")
67+
async def health() -> dict:
68+
""" health check endpoint for docker """
69+
return {
70+
"status": "healthy",
71+
"service": "netdriver-simunet"
72+
}
73+
74+
5875
def start():
5976
"""Start the simunet server with optional configuration file parameter."""
6077
parser = argparse.ArgumentParser(description="NetDriver SimuNet Server")

projects/simunet/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ ENV PYTHONUNBUFFERED=1
5252
ENV FATSTAPI_ENV=production
5353
ENV NETDRIVER_CONFIG_PATH=/app/config/simunet/simunet.yml
5454

55+
# Health check
56+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
57+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8001/health')" || exit 1
58+
5559
# Run simunet
5660
CMD ["uvicorn", "netdriver.simunet.main:app", "--host", "0.0.0.0", "--port", "8001"]

0 commit comments

Comments
 (0)