A lightweight HTTP REST API for systemd service management written in Rust.
sysdik provides a simple and efficient way to manage systemd services through HTTP endpoints. Built with modern Rust technologies, it offers a clean REST API with automatic OpenAPI documentation and Swagger UI integration.
- Service Management: Start, stop, restart, and reload systemd services
- Status Monitoring: Get detailed service status and information
- Log Access: Retrieve service logs with filtering options
- System Control: Reload systemd daemon and send custom signals
- Unit Listing: Browse all available systemd units
- API Documentation: Auto-generated OpenAPI specs with Swagger UI
- Lightweight: Minimal resource usage with async Rust performance
Install and start the service using the prebuilt binary:
curl -fsSL https://raw.githubusercontent.com/vffuunnyy/sysdik/main/install.sh | sudo bash
This script will:
- Download the latest release binary
- Install it to
/usr/local/bin/sysdik
- Create systemd service file at
/etc/systemd/system/sysdik.service
- Enable and start the service
- Download the latest release from GitHub Releases
- Extract and copy the binary to
/usr/local/bin/
- Create a systemd service file (see
systemd/sysdik.service
example) - Enable and start the service
git clone https://github.com/vffuunnyy/sysdik.git
cd sysdik
cargo build --release
sudo cp target/release/sysdik /usr/local/bin/
# Default configuration (0.0.0.0:3000)
sudo sysdik
# Custom host and port
sudo sysdik --host 127.0.0.1 --port 8080
# Using environment variables
export SYSDIK_HOST=127.0.0.1
export SYSDIK_PORT=8080
sudo sysdik
Once running, the API will be available at http://localhost:3000
(or your configured address).
# Get service information
curl http://localhost:3000/service/docker/info
# Start a service
curl -X POST http://localhost:3000/service/docker/start
# Stop a service
curl -X POST http://localhost:3000/service/docker/stop
# Restart a service
curl -X POST http://localhost:3000/service/docker/restart
# Get service status
curl http://localhost:3000/service/docker/status
# Reload service configuration
curl -X POST http://localhost:3000/service/docker/reload
# List all units
curl http://localhost:3000/units
# Reload systemd daemon
curl -X POST http://localhost:3000/daemon/reload
# Send signal to service (e.g., SIGTERM = 15)
curl -X POST http://localhost:3000/service/docker/kill/15
# Get recent logs
curl http://localhost:3000/service/docker/logs
# Get logs with parameters
curl "http://localhost:3000/service/docker/logs?lines=50&since=2024-01-01"
Interactive Swagger UI documentation is available at:
- Swagger UI:
http://localhost:3000/docs
- OpenAPI JSON:
http://localhost:3000/openapi.json
- OpenAPI YAML:
http://localhost:3000/openapi.yaml
{
"name": "docker.service",
"description": "Docker Application Container Engine",
"load_state": "loaded",
"active_state": "active",
"sub_state": "running"
}
SYSDIK_HOST
: Bind address (default:0.0.0.0
)SYSDIK_PORT
: Port number (default:3000
)
Configure logging levels using the RUST_LOG
environment variable:
export RUST_LOG=info,sysdik=debug
- Root Privileges: Requires root privileges to interact with systemd
- Network Access: Consider firewall rules and access restrictions
- Authentication: No built-in authentication - use reverse proxy if needed
- Linux system with systemd
- Root or appropriate sudo permissions
- Network access to the configured port
- Language: Rust (2024 edition)
- Web Framework: Axum
- Async Runtime: Tokio
- Systemd Integration: zbus (D-Bus client)
- Documentation: utoipa (OpenAPI generation)
- Logging: tracing + tracing-subscriber
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
This project is open source. See the LICENSE file for details.