Files
TurboTrades/DEPLOY.md
iDefineHD f9156897ce
Some checks failed
Deploy to Production / Deploy to turbotrades.dev (push) Has been cancelled
Deploy: Migrate to Gitea Actions, update paths for turbotrades.dev
2026-01-11 00:15:14 +00:00

5.3 KiB

🚀 TurboTrades - Simple Deployment

Quick deployment guide for TurboTrades on turbotrades.dev.


📋 Server Setup (Already Done)


🎯 Quick Deploy

SSH to Server and Run Deploy Script

# SSH into server
ssh root@turbotrades.dev

# Navigate to backend directory
cd /root/ttbackend

# Pull latest code
git pull origin main

# Run deploy script
./deploy.sh

That's it!


🔄 What the Deploy Script Does

  1. ⏸️ Stops the backend (PM2)
  2. 💾 Creates a backup
  3. 📥 Pulls latest code from Gitea
  4. 📦 Installs backend dependencies
  5. 🎨 Builds frontend
  6. 🚀 Deploys frontend to /var/www/html/turbotrades
  7. ▶️ Restarts backend with PM2
  8. Runs health checks

🛠️ Manual Deploy (Without Script)

# SSH to server
ssh root@turbotrades.dev

# Stop backend
pm2 stop turbotrades-backend

# Navigate to backend
cd /root/ttbackend

# Pull latest code
git pull origin main

# Install backend dependencies
npm ci --production

# Build frontend
cd frontend
npm ci
npm run build

# Deploy frontend
rm -rf /var/www/html/turbotrades/*
cp -r dist/* /var/www/html/turbotrades/
chown -R www-data:www-data /var/www/html/turbotrades

# Back to backend
cd /root/ttbackend

# Restart backend
pm2 restart turbotrades-backend
pm2 save

# Check status
pm2 logs turbotrades-backend

📊 Monitoring

Check Backend Status

pm2 list
pm2 logs turbotrades-backend
pm2 monit

Check Nginx Logs

tail -f /var/log/nginx/turbotrades-error.log
tail -f /var/log/nginx/api-turbotrades-error.log
tail -f /var/log/nginx/ws-turbotrades-error.log

Health Checks

# Backend API
curl https://api.turbotrades.dev/api/health

# Frontend
curl https://turbotrades.dev

# WebSocket (requires wscat)
wscat -c wss://ws.turbotrades.dev

🐛 Quick Troubleshooting

Backend Won't Start

# Check logs
pm2 logs turbotrades-backend

# Check if port 3000 is free
netstat -tulpn | grep 3000

# Check MongoDB
systemctl status mongod

# Restart everything
pm2 restart turbotrades-backend

Frontend Not Loading

# Check if files exist
ls -la /var/www/html/turbotrades/

# Check permissions
chown -R www-data:www-data /var/www/html/turbotrades
chmod -R 755 /var/www/html/turbotrades

# Check nginx
nginx -t
systemctl reload nginx

502 Bad Gateway

# Backend is probably down
pm2 restart turbotrades-backend

# Check backend is listening
netstat -tulpn | grep 3000

# Check nginx logs
tail -f /var/log/nginx/api-turbotrades-error.log

🔄 Rollback

# SSH to server
ssh root@turbotrades.dev

# Stop current version
pm2 stop turbotrades-backend

# List backups
ls -lt /root/ | grep ttbackend-backup

# Restore from backup
cd /root
rm -rf ttbackend
cp -r ttbackend-backup-YYYYMMDD-HHMMSS ttbackend

# Restart
cd ttbackend
pm2 restart turbotrades-backend

📝 Update .env

If you need to update environment variables:

ssh root@turbotrades.dev
cd /root/ttbackend
nano .env

# After editing, restart
pm2 restart turbotrades-backend

🎯 Deployment Workflow

For Code Changes

# On your local machine
git add .
git commit -m "Your changes"
git push origin main

# On the server
ssh root@turbotrades.dev
cd /root/ttbackend
./deploy.sh

For Environment Changes Only

ssh root@turbotrades.dev
cd /root/ttbackend
nano .env
pm2 restart turbotrades-backend

For Frontend Only

ssh root@turbotrades.dev
cd /root/ttbackend
git pull origin main
cd frontend
npm ci
npm run build
rm -rf /var/www/html/turbotrades/*
cp -r dist/* /var/www/html/turbotrades/
chown -R www-data:www-data /var/www/html/turbotrades

For Backend Only

ssh root@turbotrades.dev
cd /root/ttbackend
git pull origin main
npm ci --production
pm2 restart turbotrades-backend

🔐 Required Environment Variables

Make sure these are set in /root/ttbackend/.env:

NODE_ENV=production
PORT=3000

FRONTEND_URL=https://turbotrades.dev
BACKEND_URL=https://api.turbotrades.dev
WS_URL=https://ws.turbotrades.dev

MONGODB_URI=mongodb://localhost:27017/turbotrades

JWT_SECRET=your-secret
REFRESH_TOKEN_SECRET=your-secret
SESSION_SECRET=your-secret

STEAM_API_KEY=your-key
STEAM_REALM=https://turbotrades.dev
STEAM_RETURN_URL=https://api.turbotrades.dev/auth/steam/return

Post-Deployment Checklist

  • Backend is running (pm2 list)
  • Frontend loads (visit https://turbotrades.dev)
  • API responds (curl https://api.turbotrades.dev/api/health)
  • Steam login works
  • WebSocket connects
  • No errors in PM2 logs
  • No errors in Nginx logs

🆘 Emergency Contacts


🎉 Done!

Your TurboTrades instance is now deployed and running!

Happy Trading! 🚀