✅ Service Integration: - Integrated metrics, risk monitoring, alerts, and caching into orchestrator - Added real-time risk monitoring during deal execution - Metrics recording for all deal operations ✅ Blockchain Integration: - Implemented ethers.js blockchain service - Real WETH wrapping with transaction confirmation - Gas estimation and price fetching - Transaction simulation before execution ✅ Redis Setup: - Redis configuration and client creation - Health check utilities - Integration with cache service ✅ HSM Configuration: - Complete HSM config for Vault, AWS KMS, Azure, GCP - Configuration validation - Key rotation settings ✅ Proxmox Deployment: - Automated deployment script - Systemd service configuration - Health checks and status monitoring ✅ Integration Tests: - Full deal execution flow tests - Risk monitoring integration tests - Caching integration tests ✅ Monitoring Dashboards: - Grafana dashboard JSON configuration - 11 panels covering all key metrics - LTV, exposure, profit, transactions, errors
150 lines
3.8 KiB
Bash
Executable File
150 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Deploy Arbitrage Service to Proxmox VE Container
|
|
# Usage: ./scripts/deploy-to-proxmox.sh [VMID] [environment]
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../../.." && pwd)"
|
|
ARBITRAGE_DIR="$PROJECT_ROOT/dbis_core/src/core/defi/arbitrage"
|
|
|
|
# Configuration
|
|
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.10}"
|
|
VMID="${1:-10150}" # Default to primary API container
|
|
ENVIRONMENT="${2:-production}"
|
|
DEPLOY_USER="${DEPLOY_USER:-dbis}"
|
|
DEPLOY_PATH="/opt/dbis-core/src/core/defi/arbitrage"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
|
|
|
# Check prerequisites
|
|
check_prerequisites() {
|
|
log_info "Checking prerequisites..."
|
|
|
|
# Check SSH access
|
|
if ! ssh -o ConnectTimeout=5 root@"$PROXMOX_HOST" "echo 'SSH OK'" >/dev/null 2>&1; then
|
|
log_error "Cannot SSH to Proxmox host: $PROXMOX_HOST"
|
|
exit 1
|
|
fi
|
|
|
|
# Check container exists
|
|
if ! ssh root@"$PROXMOX_HOST" "pct status $VMID" >/dev/null 2>&1; then
|
|
log_error "Container $VMID does not exist on $PROXMOX_HOST"
|
|
exit 1
|
|
fi
|
|
|
|
log_info "Prerequisites check passed"
|
|
}
|
|
|
|
# Build the project
|
|
build_project() {
|
|
log_info "Building project..."
|
|
|
|
cd "$PROJECT_ROOT/dbis_core"
|
|
|
|
if ! pnpm build; then
|
|
log_error "Build failed"
|
|
exit 1
|
|
fi
|
|
|
|
log_info "Build successful"
|
|
}
|
|
|
|
# Deploy to container
|
|
deploy_to_container() {
|
|
log_info "Deploying to container $VMID..."
|
|
|
|
# Create directory structure
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- mkdir -p $DEPLOY_PATH"
|
|
|
|
# Copy files
|
|
log_info "Copying files..."
|
|
ssh root@"$PROXMOX_HOST" "pct push $VMID $ARBITRAGE_DIR $DEPLOY_PATH --recursive"
|
|
|
|
# Install dependencies (if package.json exists)
|
|
if [ -f "$ARBITRAGE_DIR/package.json" ]; then
|
|
log_info "Installing dependencies..."
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- bash -c 'cd $DEPLOY_PATH && npm install --production'"
|
|
fi
|
|
|
|
log_info "Deployment complete"
|
|
}
|
|
|
|
# Configure service
|
|
configure_service() {
|
|
log_info "Configuring service..."
|
|
|
|
# Create systemd service file
|
|
SERVICE_FILE="/etc/systemd/system/dbis-arbitrage.service"
|
|
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- bash -c 'cat > $SERVICE_FILE << EOF
|
|
[Unit]
|
|
Description=DBIS Deal Orchestration Service
|
|
After=network.target postgresql.service redis.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=$DEPLOY_USER
|
|
WorkingDirectory=$DEPLOY_PATH
|
|
Environment=NODE_ENV=$ENVIRONMENT
|
|
EnvironmentFile=/opt/dbis-core/.env
|
|
ExecStart=/usr/bin/node $DEPLOY_PATH/dist/cli.js execute
|
|
Restart=always
|
|
RestartSec=10
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF'"
|
|
|
|
# Reload systemd
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- systemctl daemon-reload"
|
|
|
|
log_info "Service configured"
|
|
}
|
|
|
|
# Start service
|
|
start_service() {
|
|
log_info "Starting service..."
|
|
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- systemctl enable dbis-arbitrage"
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- systemctl start dbis-arbitrage"
|
|
|
|
# Wait and check status
|
|
sleep 2
|
|
if ssh root@"$PROXMOX_HOST" "pct exec $VMID -- systemctl is-active --quiet dbis-arbitrage"; then
|
|
log_info "Service started successfully"
|
|
else
|
|
log_error "Service failed to start"
|
|
ssh root@"$PROXMOX_HOST" "pct exec $VMID -- journalctl -u dbis-arbitrage -n 20"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
log_info "Starting deployment to Proxmox VE"
|
|
log_info "Target: Container $VMID on $PROXMOX_HOST"
|
|
log_info "Environment: $ENVIRONMENT"
|
|
|
|
check_prerequisites
|
|
build_project
|
|
deploy_to_container
|
|
configure_service
|
|
start_service
|
|
|
|
log_info "Deployment complete!"
|
|
log_info "Check status: ssh root@$PROXMOX_HOST 'pct exec $VMID -- systemctl status dbis-arbitrage'"
|
|
}
|
|
|
|
main "$@"
|