-
Notifications
You must be signed in to change notification settings - Fork 93
Support health checks #33
Copy link
Copy link
Closed
Description
Summary
Add health check support to monitor box health and detect failures.
Motivation
- Detect unresponsive applications inside boxes
- Enable automatic recovery when combined with restart policies
- Standard container feature expected by users
Proposed API
Rust
let options = BoxOptions {
healthcheck: Some(Healthcheck {
command: vec!["curl", "-f", "http://localhost:8080/health"],
interval: Duration::from_secs(30),
timeout: Duration::from_secs(10),
retries: 3,
start_period: Duration::from_secs(60),
}),
..Default::default()
};
// Query health status
let info = box.info()?;
match info.health_status {
HealthStatus::Healthy => println!("Box is healthy"),
HealthStatus::Unhealthy => println!("Box failed health check"),
HealthStatus::Starting => println!("Health check starting..."),
HealthStatus::None => println!("No health check configured"),
}Python
box = SimpleBox(
image="python:slim",
healthcheck={
"command": ["python", "-c", "import requests; requests.get('http://localhost:8080/health')"],
"interval": 30,
"timeout": 10,
"retries": 3,
}
)
info = await box.info()
print(f"Health: {info.health_status}")Health States
| State | Description |
|---|---|
None |
No health check configured |
Starting |
Within start_period, not yet checked |
Healthy |
Last health check passed |
Unhealthy |
Failed retries consecutive checks |
Integration
- When unhealthy + restart policy set → trigger restart
- Expose health status in
box.info()and metrics - Log health check failures
Tasks
- Add Healthcheck struct and HealthStatus enum
- Implement health check executor (runs command in box)
- Add background health check loop
- Store health status in BoxState
- Integrate with restart policies
- Update Python SDK
- Add tests and documentation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels