Hammerwork Web Dashboard
A modern, real-time web-based admin dashboard for monitoring and managing Hammerwork job queues. Built with Rust, Warp, and WebSockets for high-performance job queue administration.
Features
- Real-time Monitoring: Live updates via WebSockets for queue statistics, job status, and system health
- Job Management: View, retry, cancel, and inspect jobs with detailed payload and error information
- Spawn Operation Management: Monitor job spawning, visualize parent-child relationships, and track spawn trees
- Job Archive Management: Archive, restore, and purge jobs with configurable retention policies
- Queue Administration: Monitor queue performance, clear queues, and manage queue priorities
- Archive Statistics: Track storage savings, compression ratios, and archival operations
- Multi-Database Support: Works with both PostgreSQL and MySQL backends
- Security: Built-in authentication with bcrypt password hashing and rate limiting
- Modern UI: Responsive dashboard with charts, tables, and real-time indicators
- REST API: Complete RESTful API for programmatic access
- High Performance: Async/await throughout with efficient database pooling
Screenshots
The dashboard provides:
- Overview Cards: Total jobs, pending/running counts, error rates, and throughput
- Queue Table: Real-time queue statistics with actions (clear, pause, resume)
- Jobs Table: Filterable job listing with status, priority, and actions
- Archive Section: Archived jobs management with statistics and restoration capabilities
- Charts: Throughput over time and job status distribution
- Real-time Updates: WebSocket connections for live data updates
Quick Start
Installation
# Install from crates.io
# Or build from source
Basic Usage
# Start the dashboard (PostgreSQL)
# Start with authentication enabled
# Start with custom port and CORS enabled
Configuration File
Create a dashboard.toml configuration file:
= "0.0.0.0"
= 8080
= "postgresql://localhost/hammerwork"
= 10
= "./assets"
= false
= "30s"
[]
= true
= "admin"
= "$2b$12$..." # bcrypt hash
= "8h"
= 5
= "15m"
[]
= "30s"
= 100
= 1024
= 65536
Then start with:
Library Usage
Add to your Cargo.toml:
[]
= { = "1.3", = ["postgres"] }
# or for MySQL:
# hammerwork-web = { version = "1.3", features = ["mysql"] }
Programmatic Usage
use ;
use Duration;
async
With Authentication
use ;
let config = new
.with_database_url
.with_bind_address
.with_auth // bcrypt hash
.with_cors;
let dashboard = new.await?;
dashboard.start.await?;
API Reference
The dashboard exposes a complete REST API:
Authentication
All API endpoints (except /health) require authentication when enabled:
Endpoints
System
GET /health- Health check (no auth required)GET /api/stats/overview- System overview statisticsGET /api/stats/throughput?period=24h- Throughput data
Queues
GET /api/queues- List all queues with statisticsPOST /api/queues/{name}/clear- Clear all jobs from queuePOST /api/queues/{name}/pause- Pause queue processingPOST /api/queues/{name}/resume- Resume queue processing
Jobs
GET /api/jobs?status=failed&limit=50- List jobs with filtersGET /api/jobs/{id}- Get job detailsPOST /api/jobs- Create new jobPOST /api/jobs/{id}/retry- Retry failed jobDELETE /api/jobs/{id}- Delete job
Archive Management
GET /api/archive/jobs?queue=email&limit=50- List archived jobs with filtersPOST /api/archive/jobs- Archive jobs based on configurable policyPOST /api/archive/jobs/{id}/restore- Restore an archived job to pending statusDELETE /api/archive/purge- Permanently purge old archived jobsGET /api/archive/stats?queue=email- Get archive statistics and metrics
Spawn Operations
GET /api/spawn/info- List available spawn API endpointsGET /api/jobs/{id}/children?include_grandchildren=true- List spawned child jobsGET /api/jobs/{id}/parent- Get parent job informationGET /api/jobs/{id}/spawn-tree?format=json&max_depth=5- Get complete spawn hierarchyGET /api/spawn/operations?limit=50- List spawn operationsGET /api/spawn/operations/{id}- Get spawn operation detailsPOST /api/jobs/{id}/spawn- Manually trigger spawn operationGET /api/spawn/stats?queue=data_processing- Get spawn operation statistics
WebSocket API
Connect to ws://localhost:8080/ws for real-time updates:
const ws = ;
// Subscribe to events
ws.;
// Handle updates
ws ;
Development
Prerequisites
- Rust 1.70+
- PostgreSQL or MySQL database
- Node.js (for frontend development)
Database Setup
Use the provided scripts to set up test databases:
# Set up both PostgreSQL and MySQL test databases
# PostgreSQL only
# MySQL only
Default test database connections:
- PostgreSQL:
postgresql://postgres:hammerwork@localhost:5433/hammerwork - MySQL:
mysql://root:hammerwork@localhost:3307/hammerwork
Building
# Build with PostgreSQL support
# Build with MySQL support
# Build with authentication support
# Build everything
Testing
# Unit tests
# Integration tests (requires database)
# Test with both databases
Development Commands
# Format code
# Lint code
# Run with hot reload (requires cargo-watch)
# Generate documentation
Frontend Development
The dashboard frontend is built with vanilla JavaScript, HTML, and CSS for minimal dependencies and fast loading.
Asset Structure
assets/
├── index.html # Main dashboard page
├── dashboard.css # Styles and responsive design
├── dashboard.js # WebSocket client and UI logic
└── chart.min.js # Chart.js for data visualization
Adding Features
- New API Endpoint: Add to appropriate module in
src/api/ - WebSocket Message: Update
ServerMessageenum insrc/websocket.rs - Frontend Component: Add to
assets/dashboard.jsand update UI inindex.html - Tests: Add unit tests in module and integration tests in
tests/
Archive API Examples
# List archived jobs
# Archive completed jobs older than 7 days
# Restore an archived job
# Get archive statistics
Security
Authentication
- Basic Authentication: RFC 7617 compliant with base64 encoding
- Password Hashing: bcrypt with configurable cost (default: 12)
- Rate Limiting: Failed login attempt tracking with account lockout
- Session Management: Configurable session timeouts
Best Practices
- Change default credentials immediately
- Use strong passwords (12+ characters)
- Enable authentication in production
- Use HTTPS in production
- Configure firewall rules appropriately
- Store password hashes securely
- Regular security updates
Example: Generate Password Hash
# Using bcrypt command-line tool
|
# Or in Rust
;
Deployment
Docker
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release --features postgres
FROM debian:booksworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/hammerwork-web /usr/local/bin/
COPY --from=builder /app/hammerwork-web/assets /app/assets
WORKDIR /app
EXPOSE 8080
CMD ["hammerwork-web", "--bind", "0.0.0.0", "--port", "8080"]
systemd Service
[Unit]
Description=Hammerwork Web Dashboard
After=network.target postgresql.service
[Service]
Type=simple
User=hammerwork
WorkingDirectory=/opt/hammerwork
ExecStart=/opt/hammerwork/hammerwork-web --config /etc/hammerwork/dashboard.toml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Nginx Reverse Proxy
server {
listen 80;
server_name hammerwork.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
Performance
Optimization Tips
- Connection Pooling: Tune
pool_sizebased on concurrent users - WebSocket Limits: Configure
max_connectionsfor your use case - Request Timeouts: Set appropriate
request_timeoutfor your network - Database Indexes: Ensure proper indexes on hammerwork_jobs table
- Static Assets: Use a CDN for production deployments
- Monitoring: Enable structured logging and metrics collection
Monitoring
# Enable debug logging
RUST_LOG=hammerwork_web=debug
# Monitor WebSocket connections
|
# Database connection health
Troubleshooting
Common Issues
Database Connection Failed
Error: Database connection failed
- Verify database URL format and credentials
- Check database server is running and accessible
- Ensure database exists and migrations are applied
Static Assets Not Found
Error: Static file not found
- Check
static_dirpath in configuration - Ensure assets directory contains
index.html - Verify file permissions
Authentication Issues
401 Unauthorized
- Verify username and password
- Check password hash format (bcrypt)
- Review rate limiting settings
WebSocket Connection Failed
WebSocket connection closed unexpectedly
- Check firewall settings for WebSocket traffic
- Verify proxy configuration for Upgrade headers
- Review browser console for detailed errors
Debug Mode
# Enable verbose logging
RUST_LOG=debug
# Enable specific module logging
RUST_LOG=hammerwork_web::websocket=trace
Contributing
We welcome contributions! Please see the main CONTRIBUTING.md for guidelines.
Areas for Contribution
- Additional database backends (SQLite, CockroachDB)
- Enhanced security features (OAuth, JWT)
- More visualization options (metrics dashboards)
- Archive management enhancements (scheduled policies, bulk operations)
- Real-time WebSocket events for archive operations
- Mobile-responsive improvements
- Internationalization (i18n)
- Plugin system for custom integrations
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for version history and changes.