mirror of
https://github.com/DeNNiiInc/Connect-5.git
synced 2026-04-17 22:46:00 +00:00
- Created automated deploy-production.sh script - Added comprehensive PRODUCTION_DEPLOY.md guide - Includes troubleshooting and Apache configuration - Ready for production deployment
4.8 KiB
4.8 KiB
Production Deployment Guide
Quick Deployment
Option 1: Automated Script (Recommended)
-
Upload the deployment script to your production server:
scp deploy-production.sh user@connect5.beyondcloud.technology:/tmp/ -
SSH into your server:
ssh user@connect5.beyondcloud.technology -
Update the script path (if needed):
nano /tmp/deploy-production.sh # Change PROJECT_DIR to your actual path -
Make it executable and run:
chmod +x /tmp/deploy-production.sh sudo /tmp/deploy-production.sh
Option 2: Manual Steps
If you prefer manual deployment:
-
SSH into production server:
ssh user@connect5.beyondcloud.technology -
Navigate to project:
cd /var/www/html/connect5.beyondcloud.technology # Your actual path -
Pull latest code:
git pull origin main npm install -
Create db.config.js:
nano db.config.jsPaste:
module.exports = { supabaseUrl: 'https://wxtirlphaphwbrgsjyop.supabase.co', supabaseAnonKey: 'sb_publishable_Onh4nNYCV99d2eGidQIpqA_9PBkY8zs', supabasePassword: 't1hWsackxbYzRIPD', postgresConnectionString: 'postgresql://postgres:t1hWsackxbYzRIPD@db.wxtirlphaphwbrgsjyop.supabase.co:5432/postgres' };Save with
Ctrl+X,Y,Enter -
Restart server:
pm2 restart connect5 # or if not running: pm2 start server.js --name connect5 pm2 save -
Check status:
pm2 status pm2 logs connect5
Verification
1. Test API Endpoint
curl https://connect5.beyondcloud.technology/api/db-status
Should return JSON like:
{
"connected": true,
"latency": 45,
"writeCapable": true,
"database": "Supabase PostgreSQL"
}
2. Test in Browser
- Visit https://connect5.beyondcloud.technology/
- Check status bar at bottom:
- SQL: Connected (green)
- Latency: ~45ms
- Write: Enabled (green)
- Click "Multiplayer"
- Enter a username
- Should see "Welcome back, [username]!"
3. Test Multiplayer
- Open two browser windows
- Register different usernames in each
- Send a challenge from one to the other
- Accept and play a game
- Verify stats update after game ends
Troubleshooting
API Returns 404
Check if Node.js is running:
pm2 status
Check Apache proxy:
sudo nano /etc/apache2/sites-available/connect5.conf
Should have:
ProxyPass /api http://localhost:3000/api
ProxyPassReverse /api http://localhost:3000/api
ProxyPass /socket.io http://localhost:3000/socket.io
ProxyPassReverse /socket.io http://localhost:3000/socket.io
Restart Apache:
sudo systemctl restart apache2
WebSocket Connection Fails
Enable Apache modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod rewrite
sudo systemctl restart apache2
Database Connection Fails
Check Supabase credentials:
cat db.config.js
Test connection:
node -e "const {supabase} = require('./database'); supabase.from('players').select('id').limit(1).then(console.log)"
Server Won't Start
Check logs:
pm2 logs connect5 --lines 50
Check port availability:
sudo netstat -tlnp | grep 3000
Post-Deployment
Monitor Server
pm2 monit
View Logs
pm2 logs connect5 --lines 100
Restart if Needed
pm2 restart connect5
Update Later
cd /var/www/html/connect5.beyondcloud.technology
git pull origin main
npm install
pm2 restart connect5
Apache Configuration Reference
If you need to set up Apache proxy from scratch:
<VirtualHost *:443>
ServerName connect5.beyondcloud.technology
DocumentRoot /var/www/html/connect5.beyondcloud.technology
<Directory /var/www/html/connect5.beyondcloud.technology>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Proxy API and Socket.io to Node.js
ProxyPreserveHost On
ProxyPass /api http://localhost:3000/api
ProxyPassReverse /api http://localhost:3000/api
ProxyPass /socket.io http://localhost:3000/socket.io
ProxyPassReverse /socket.io http://localhost:3000/socket.io
# WebSocket support
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:3000/$1 [P,L]
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/connect5.beyondcloud.technology/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/connect5.beyondcloud.technology/privkey.pem
</VirtualHost>
Apply changes:
sudo systemctl restart apache2