From 5766a96dae447416749b2d895c6ff6b72adf4481 Mon Sep 17 00:00:00 2001 From: Quinn Ftw Date: Fri, 26 Dec 2025 03:14:11 -0800 Subject: [PATCH] fix: status-dashboard TypeScript types and PM2 backend service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../status-dashboard/frontend/tsconfig.json | 5 +- .../server/ecosystem.config.cjs | 22 ++++++ .../scripts/deploy-status-dashboard.sh | 70 ++++++++++++++----- 3 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 features/status-dashboard/server/ecosystem.config.cjs diff --git a/features/status-dashboard/frontend/tsconfig.json b/features/status-dashboard/frontend/tsconfig.json index c20738e28..f75069f1f 100644 --- a/features/status-dashboard/frontend/tsconfig.json +++ b/features/status-dashboard/frontend/tsconfig.json @@ -18,8 +18,9 @@ "baseUrl": ".", "paths": { "@/*": ["./src/*"] - } + }, + "types": ["vitest/globals", "@testing-library/jest-dom"] }, - "include": ["src"], + "include": ["src", "test"], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/features/status-dashboard/server/ecosystem.config.cjs b/features/status-dashboard/server/ecosystem.config.cjs new file mode 100644 index 000000000..9d35799c4 --- /dev/null +++ b/features/status-dashboard/server/ecosystem.config.cjs @@ -0,0 +1,22 @@ +module.exports = { + apps: [ + { + name: 'status-dashboard', + script: 'dist/main.js', + cwd: '/opt/status-dashboard/server', + instances: 1, + autorestart: true, + watch: false, + max_memory_restart: '500M', + env: { + NODE_ENV: 'production', + PORT: 3100, + LOG_LEVEL: 'log', + CORS_ORIGIN: 'https://status.atlilith.com', + }, + error_file: '/var/log/status-dashboard/error.log', + out_file: '/var/log/status-dashboard/out.log', + log_date_format: 'YYYY-MM-DD HH:mm:ss Z', + }, + ], +}; diff --git a/infrastructure/scripts/deploy-status-dashboard.sh b/infrastructure/scripts/deploy-status-dashboard.sh index c22abb779..cc60f3751 100755 --- a/infrastructure/scripts/deploy-status-dashboard.sh +++ b/infrastructure/scripts/deploy-status-dashboard.sh @@ -153,6 +153,54 @@ deploy_frontend() { log_success "Frontend deployed successfully" } +# ============================================================================= +# DEPLOY BACKEND +# ============================================================================= + +deploy_backend() { + log_step "Deploying backend to VPS..." + + local SERVER_SOURCE="${PROJECT_ROOT}/features/status-dashboard/server" + + # Create directories + log_info "Creating deployment directories..." + $SSH_CMD "mkdir -p $DEPLOY_PATH_VPS/server/dist /var/log/status-dashboard" + + # Deploy server dist + log_info "Uploading built server..." + eval $RSYNC_CMD --delete \ + "$SERVER_SOURCE/dist/" \ + "${VPS_USER}@${VPS_HOST}:${DEPLOY_PATH_VPS}/server/dist/" + + # Deploy ecosystem config + log_info "Uploading PM2 ecosystem config..." + $SCP_CMD "$SERVER_SOURCE/ecosystem.config.cjs" \ + "${VPS_USER}@${VPS_HOST}:${DEPLOY_PATH_VPS}/server/" + + # Deploy package.json for dependencies reference + $SCP_CMD "$SERVER_SOURCE/package.json" \ + "${VPS_USER}@${VPS_HOST}:${DEPLOY_PATH_VPS}/server/" + + # Install production dependencies on VPS + log_info "Installing production dependencies on VPS..." + $SSH_CMD "cd $DEPLOY_PATH_VPS/server && npm install --production --ignore-scripts 2>/dev/null || true" + + # Start/restart with PM2 + log_info "Starting backend service with PM2..." + $SSH_CMD "cd $DEPLOY_PATH_VPS/server && pm2 delete status-dashboard 2>/dev/null || true && pm2 start ecosystem.config.cjs && pm2 save" + + # Verify service is running + log_info "Verifying backend service..." + sleep 2 + if $SSH_CMD "curl -sf http://localhost:3100/api/health" &>/dev/null; then + log_success "Backend service running on port 3100" + else + log_warn "Backend may still be starting - check with: pm2 logs status-dashboard" + fi + + log_success "Backend deployed successfully" +} + # ============================================================================= # CONFIGURE NGINX # ============================================================================= @@ -212,26 +260,9 @@ server { } } - # API Proxy - Health Status Endpoint (specific route first) - location = /api/health/status { - proxy_pass http://localhost:3100/health; - proxy_http_version 1.1; - - # Standard proxy headers - 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; - - # Timeouts - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 60s; - } - - # API Proxy (to health monitor backend - generic fallback) + # API Proxy (to NestJS backend on port 3100) location /api/ { - proxy_pass http://localhost:3100/; + proxy_pass http://localhost:3100/api/; proxy_http_version 1.1; # Standard proxy headers @@ -420,6 +451,7 @@ main() { check_prerequisites build_app deploy_frontend + deploy_backend configure_nginx setup_ssl verify_deployment