A lightweight and customizable healthcheck service built with Rust and Axum. It supports multiple ports and paths configured through environment variables, making it ideal for scenarios requiring dynamic health checks, such as AWS Network Load Balancer (NLB) integrations.
- Responds with
HTTP 200 OK
to any configured path. - Supports multiple ports and paths defined via environment variables.
- Graceful shutdown on receiving a termination signal (e.g.,
Ctrl+C
). - Logs incoming requests to the console.
The service uses environment variables to configure its behavior:
PORT
orPORTS
: Comma-separated list of ports to listen on. Example:PORTS=8080,8081
.HEALTHCHECK
orHEALTHCHECK_PATH
: Comma-separated list of healthcheck paths. Example:HEALTHCHECK_PATH=/health,/status
.
PORT=8080,8081
HEALTHCHECK=/health,/status
- Rust toolchain
- Docker (optional for containerized deployment)
- Clone the repository:
git clone <repository_url>
cd <repository_name>
- Build the binary:
cargo build --release
- Run the binary:
PORT=8080 HEALTHCHECK=/health ./target/release/healthcheck
- Build the Docker image:
docker build -t healthcheck-service .
- Run the container:
docker run -e PORT=8080,8081 -e HEALTHCHECK=/health -p 8080:8080 -p 8081:8081 healthcheck-service
src/main.rs
: Main application logic, including router setup and graceful shutdown.Dockerfile
: Multi-stage build for an optimized container image.Cargo.toml
: Dependency and configuration file for Rust.
This project is licensed under the MIT License.