
- Changed repository cloning instructions to use `DeepSea-Dashboard`. - Adjusted the position of the `lowHashrateIndicator` in `main.js` from bottom to top right. - Added a background color to the indicator for improved visibility.
8.5 KiB
Deployment Guide
This guide provides comprehensive instructions for deploying the Bitcoin Mining Dashboard application in various environments, from development to production.
Prerequisites
- Python 3.9 or higher
- Redis server (optional, for persistent state and improved reliability)
- Docker and Docker Compose (optional, for containerized deployment)
- Network access to Ocean.xyz API endpoints
- Modern web browser (Chrome, Firefox, Edge recommended)
Installation Options
Option 1: Standard Installation (Development)
-
Clone the repository:
git clone https://github.com/Djobleezy/DeepSea-Dashboard.git cd DeepSea-Dashboard
-
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the setup script to organize files:
python setup.py
-
Start the application:
python App.py
-
Access the dashboard at
http://localhost:5000
Option 2: Production Deployment with Gunicorn
For better performance and reliability in production environments:
-
Follow steps 1-5 from standard installation
-
Install Gunicorn if not already installed:
pip install gunicorn
-
Start with Gunicorn:
gunicorn -b 0.0.0.0:5000 App:app --workers=1 --threads=12 --timeout=600 --keep-alive=5
Important
: Use only 1 worker to maintain shared state. Use threads for concurrency.
-
For a more robust setup, create a systemd service:
sudo nano /etc/systemd/system/mining-dashboard.service
Add the following content:
[Unit] Description=Bitcoin Mining Dashboard After=network.target [Service] User=your_username WorkingDirectory=/path/to/bitcoin-mining-dashboard ExecStart=/path/to/venv/bin/gunicorn -b 0.0.0.0:5000 App:app --workers=1 --threads=12 --timeout=600 --keep-alive=5 Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl enable mining-dashboard sudo systemctl start mining-dashboard
Option 3: Docker Deployment
-
Build the Docker image:
docker build -t bitcoin-mining-dashboard .
-
Run the container:
docker run -d -p 5000:5000 \ -e WALLET=your-wallet-address \ -e POWER_COST=0.12 \ -e POWER_USAGE=3450 \ -v $(pwd)/logs:/app/logs \ --name mining-dashboard \ bitcoin-mining-dashboard
-
Access the dashboard at
http://localhost:5000
Option 4: Docker Compose with Redis Persistence
-
Create a
docker-compose.yml
file:version: '3' services: redis: image: redis:alpine restart: unless-stopped volumes: - redis_data:/data dashboard: build: . restart: unless-stopped ports: - "5000:5000" environment: - REDIS_URL=redis://redis:6379 - WALLET=your-wallet-address - POWER_COST=0.12 - POWER_USAGE=3450 volumes: - ./logs:/app/logs depends_on: - redis volumes: redis_data:
-
Launch the services:
docker-compose up -d
-
Access the dashboard at
http://localhost:5000
Environment Variables
The application can be configured using environment variables:
Variable | Description | Default |
---|---|---|
REDIS_URL |
Redis connection URL for persistent state | None |
WALLET |
Ocean.xyz wallet address | From config.json |
POWER_COST |
Electricity cost per kWh | From config.json |
POWER_USAGE |
Power consumption in watts | From config.json |
FLASK_ENV |
Application environment | development |
LOG_LEVEL |
Logging level | INFO |
PORT |
Application port | 5000 |
Reverse Proxy Configuration
For production deployments, it's recommended to use a reverse proxy like Nginx:
-
Install Nginx:
sudo apt update sudo apt install nginx
-
Create a configuration file:
sudo nano /etc/nginx/sites-available/mining-dashboard
-
Add the following configuration:
server { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:5000; 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_buffering off; proxy_cache off; } }
-
Create a symbolic link:
sudo ln -s /etc/nginx/sites-available/mining-dashboard /etc/nginx/sites-enabled/
-
Test and restart Nginx:
sudo nginx -t sudo systemctl restart nginx
-
(Optional) Add SSL with Certbot:
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d your-domain.com
Maintenance
Logs
Logs are stored in the logs
directory by default. Monitor these logs for errors and warnings:
tail -f logs/dashboard.log
Common log patterns to watch for:
ERROR fetching metrics
- Indicates issues with Ocean.xyz APIFailed to connect to Redis
- Redis connection problemsScheduler stopped unexpectedly
- Background job issues
Health Monitoring
Health Check Endpoint
A health check endpoint is available at /api/health
that returns:
- Application status (healthy, degraded, unhealthy)
- Uptime information
- Memory usage
- Data freshness
- Redis connection status
- Scheduler status
Example health check command:
curl http://localhost:5000/api/health | jq
Scheduler Health
To monitor the scheduler:
curl http://localhost:5000/api/scheduler-health | jq
Performance Tuning
-
Redis Configuration: For high-traffic deployments, tune Redis:
maxmemory 256mb maxmemory-policy allkeys-lru
-
Gunicorn Threads: Adjust thread count based on CPU cores:
--threads=$(( 2 * $(nproc) ))
-
Browser Cache Headers: Already optimized in the application
Troubleshooting
Common Issues
-
Application not updating data:
- Check network connectivity to Ocean.xyz
- Verify scheduler health:
curl http://localhost:5000/api/scheduler-health
- Force a data refresh:
curl -X POST http://localhost:5000/api/force-refresh
-
High memory usage:
- Check for memory leaks in log files
- Restart the application
- Enable Redis for better state management
-
Scheduler failures:
- Fix the scheduler:
curl -X POST http://localhost:5000/api/fix-scheduler
- Fix the scheduler:
-
Workers not showing:
- Verify your wallet address is correct
- Check worker data:
curl http://localhost:5000/api/workers
Recovery Procedures
If the application becomes unresponsive:
- Check the logs for error messages
- Restart the application:
sudo systemctl restart mining-dashboard
- If Redis is used and may be corrupted:
sudo systemctl restart redis
- For Docker deployments:
docker-compose restart
Updating
To update the application:
-
Pull the latest changes:
git pull origin main
-
Update dependencies:
pip install -r requirements.txt --upgrade
-
Run the setup script:
python setup.py
-
Restart the application:
sudo systemctl restart mining-dashboard
Docker Update Procedure
-
Pull the latest changes:
git pull origin main
-
Rebuild and restart:
docker-compose build docker-compose up -d
Backup Strategy
- Configuration: Regularly backup your
config.json
file - Redis Data: If using Redis, set up regular RDB snapshots
- Logs: Implement log rotation and archiving
Security Recommendations
- Run as Non-Root User: Always run the application as a non-root user
- Firewall Configuration: Restrict access to ports 5000 and 6379 (Redis)
- Redis Authentication: Enable Redis password authentication:
requirepass your_strong_password
- HTTPS: Use SSL/TLS for all production deployments
- Regular Updates: Keep all dependencies updated