A comprehensive real-time monitoring system for translation workflows with WebSocket support, SSH worker integration, and interactive web dashboard.
go run ./cmd/monitor-server- Basic Dashboard: http://localhost:8090/monitor
- Enhanced Dashboard:
enhanced-monitor.html
# Basic demo with WebSocket monitoring
go run demo-translation-with-monitoring-fixed.go
# Comprehensive demo with multiple strategies
go run demo-comprehensive-monitoring.go
# SSH worker demo (if configured)
go run demo-ssh-worker-with-monitoring.go
# Real LLM translation (requires API key)
export OPENAI_API_KEY=your_key_here
go run demo-real-llm-with-monitoring.gochmod +x scripts/run_monitoring_demo.sh
./scripts/run_monitoring_demo.sh- Live Progress Updates: WebSocket-based real-time progress tracking
- Event Streaming: Comprehensive event emission and handling
- Session Management: Multiple simultaneous translation sessions
- Error Tracking: Immediate error detection and reporting
- SSH Worker Support: Remote worker management and monitoring
- LLM Integration: Real translation with OpenAI, Anthropic, DeepSeek, etc.
- Multiple Strategies: Demo, mock-LLM, and SSH simulation modes
- Performance Tracking: Worker capacity and performance metrics
- Progress Visualization: Real-time progress bars and charts
- Event Logging: Detailed event history and filtering
- Session History: Past translation session records
- Worker Information: SSH worker status and details
βββββββββββββββββββ WebSocket Events βββββββββββββββββββββββ
β Translation CLI β βββββββββββββββββββββΊ β Monitoring Server β
βββββββββββββββββββ βββββββββββββββββββββββ
β
β WebSocket Stream
βΌ
βββββββββββββββββββββββ
β Web Dashboard β
β (Real-time UI) β
βββββββββββββββββββββββ
Remote SSH Workers:
βββββββββββββββββββ SSH Connection βββββββββββββββββββββββ
β SSH Worker 1 β ββββββββββββββββββββΊ β Translation CLI β
βββββββββββββββββββ βββββββββββββββββββββββ
βββββββββββββββββββ
β SSH Worker 2 β
βββββββββββββββββββ
cmd/monitor-server/- WebSocket monitoring serverpkg/websocket/- WebSocket hub and connection managementpkg/events/- Event system architecturepkg/sshworker/- SSH worker management
demo-translation-with-monitoring-fixed.go- Basic WebSocket monitoring demodemo-comprehensive-monitoring.go- Multi-strategy comprehensive demodemo-ssh-worker-with-monitoring.go- SSH worker integration demodemo-real-llm-with-monitoring.go- Real LLM translation demo
monitor.html- Basic monitoring dashboardenhanced-monitor.html- Advanced dashboard with SSH worker support
config.json- Main application configurationinternal/working/config.distributed.json- SSH worker configurationinternal/working/config.*.json- Various LLM provider configs
docs/WebSocket_Monitoring_Guide.md- Complete technical documentationdocs/User_Guide.md- Step-by-step user instructionsdocs/Troubleshooting_Guide.md- Common issues and solutionstests/websocket_monitoring_test.go- Comprehensive test suite
scripts/run_monitoring_demo.sh- Interactive demo script
- Real-time Events: Translation progress, errors, completion events
- Multi-client Support: Multiple dashboard connections simultaneously
- Session-based Tracking: Unique session IDs for each translation
- Automatic Reconnection: Client reconnection on connection loss
- Remote Execution: Execute translation commands on remote workers
- Connection Management: Secure SSH connection handling
- Progress Tracking: Real-time progress from remote workers
- Error Handling: Comprehensive error detection and fallback
- OpenAI: GPT-3.5, GPT-4, GPT-4 Turbo
- Anthropic: Claude-3 Opus, Claude-3 Sonnet, Claude-3 Haiku
- DeepSeek: DeepSeek Chat, DeepSeek Coder
- Zhipu: GLM-4, GLM-3 Turbo
- Qwen: Qwen Max, Qwen Plus, Qwen Turbo
- Gemini: Gemini Pro, Gemini Pro Vision
- Ollama: Local LLM support
- LlamaCpp: Local model execution
- Progress Visualization: Real-time progress bars and charts
- Event Logging: Comprehensive event history with filtering
- Session Management: Monitor multiple translation sessions
- Worker Monitoring: SSH worker status and performance
- Responsive Design: Works on desktop and mobile devices
# WebSocket Server
MONITOR_SERVER_PORT=8090
# SSH Workers
SSH_WORKER_HOST=localhost
SSH_WORKER_USER=milosvasic
SSH_WORKER_PASSWORD=your_password
SSH_WORKER_PORT=22
SSH_WORKER_REMOTE_DIR=/tmp/translate-ssh
# LLM APIs
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
DEEPSEEK_API_KEY=your_deepseek_key
ZHIPU_API_KEY=your_zhipu_key
QWEN_API_KEY=your_qwen_key
GEMINI_API_KEY=your_gemini_key
# Logging
LOG_LEVEL=info # debug, info, warn, error{
"distributed": {
"enabled": true,
"workers": {
"thinker-worker": {
"name": "Local Llama.cpp Worker",
"host": "localhost",
"port": 8444,
"user": "milosvasic",
"password": "password",
"max_capacity": 10,
"enabled": true,
"tags": ["gpu", "llamacpp"]
}
},
"ssh_timeout": 30,
"ssh_max_retries": 3,
"health_check_interval": 30
}
}# Test WebSocket server
go test ./cmd/monitor-server
# Test event system
go test ./pkg/events
# Test SSH workers
go test ./pkg/sshworker
# Run all tests
go test ./...# Test WebSocket monitoring workflow
go run demo-websocket-client.go
# Test SSH worker integration
go run demo-ssh-worker-with-monitoring.go
# Test LLM integration
go run demo-real-llm-with-monitoring.go
# Comprehensive test
go run demo-comprehensive-monitoring.go# Benchmark WebSocket performance
go test -bench=. ./tests/websocket_monitoring_test.go
# Load test with multiple clients
for i in {1..10}; do
go run demo-translation-with-monitoring-fixed.go &
done- Connection Speed: < 50ms to establish connection
- Event Latency: < 10ms per event
- Throughput: 100+ events/second
- Concurrent Clients: 50+ simultaneous connections
- Connection Time: < 5 seconds (configurable)
- Command Execution: < 1 second per translation
- Retry Logic: 3 automatic retries with exponential backoff
- Connection Pooling: Reuse connections for multiple commands
- API Response: 1-10 seconds depending on model
- Token Limits: 2000 tokens default (configurable)
- Retry Logic: Automatic retry on rate limits
- Fallback: Demo translation when API unavailable
- CORS Support: Configurable origin restrictions
- Rate Limiting: 10 requests/second (configurable)
- Authentication: API key header support (optional)
- Secure Mode: WSS support for production
- Key Authentication: SSH key support recommended
- Password Protection: Secure password handling
- Connection Limits: Configurable timeout and retry limits
- Command Restrictions: Limited command execution scope
- Key Management: Secure API key storage
- HTTPS Support: TLS termination for API calls
- Rate Limiting: Provider-specific rate limit handling
- Input Validation: Comprehensive input sanitization
# Start monitoring server
go run ./cmd/monitor-server
# Run translation with monitoring
go run demo-comprehensive-monitoring.go
# Open dashboard
open enhanced-monitor.html# Build monitoring server
go build -o monitor-server ./cmd/monitor-server
# Build translation CLI
go build -o translator ./cmd/translator
# Start monitoring server
./monitor-server -config=production.json
# Run translation with monitoring
./translator -monitor -config=production.json input.txt output.mdFROM golang:1.21-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o monitor-server ./cmd/monitor-server
RUN go build -o translator ./cmd/translator
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/monitor-server .
COPY --from=builder /app/translator .
EXPOSE 8090
CMD ["./monitor-server"]version: '3.8'
services:
monitor-server:
build: .
ports:
- "8090:8090"
environment:
- LOG_LEVEL=info
- MONITOR_SERVER_PORT=8090
volumes:
- ./config.json:/app/config.json
- ./logs:/app/logs
translator:
build: .
depends_on:
- monitor-server
environment:
- MONITOR_SERVER_URL=ws://monitor-server:8090/ws
volumes:
- ./input:/app/input
- ./output:/app/output-
WebSocket Connection Failed
- Check if monitoring server is running:
lsof -i :8090 - Start server:
go run ./cmd/monitor-server
- Check if monitoring server is running:
-
SSH Worker Connection Failed
- Test SSH connection:
ssh milosvasic@localhost - Check credentials in config files
- Test SSH connection:
-
LLM API Authentication Failed
- Verify API key:
echo $OPENAI_API_KEY - Set API key:
export OPENAI_API_KEY=your_key
- Verify API key:
-
Port Conflicts
- Find process:
lsof -i :8090 - Kill process:
kill -9 <PID> - Use different port in config
- Find process:
# Enable debug logging
export LOG_LEVEL=debug
# Run with verbose output
go run ./cmd/monitor-server -v -log-level=debug
# Monitor WebSocket traffic
websocat ws://localhost:8090/ws- WebSocket Monitoring Guide - Complete technical documentation
- User Guide - Step-by-step user instructions
- Troubleshooting Guide - Common issues and solutions
- API Documentation - REST and WebSocket API reference
# Clone repository
git clone <repository-url>
cd translate
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Start development server
go run ./cmd/monitor-server- Follow Go conventions and best practices
- Add comprehensive tests for new features
- Update documentation for API changes
- Use meaningful commit messages
- Fork repository
- Create feature branch
- Add tests and documentation
- Submit pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Gorilla WebSocket - WebSocket implementation
- Chart.js - Progress visualization charts
- Tailwind CSS - Dashboard styling
- Go Community - Various libraries and tools
For support and questions:
- Check documentation in
docs/directory - Review GitHub issues for known problems
- Contact development team for assistance
Happy Monitoring! π