mirror of
https://github.com/DeNNiiInc/Connect-5.git
synced 2026-04-17 20:36:00 +00:00
Add CloudSticks deployment script without PM2 dependency
- Created deploy-cloudsticks.sh for CloudSticks environment - Works with systemd, PM2, or direct node execution - Added CLOUDSTICKS_DEPLOY.md with specific instructions - Handles case where PM2 is not installed
This commit is contained in:
176
CLOUDSTICKS_DEPLOY.md
Normal file
176
CLOUDSTICKS_DEPLOY.md
Normal file
@@ -0,0 +1,176 @@
|
||||
# CloudSticks Deployment Guide
|
||||
|
||||
## Quick Setup (No PM2 Required)
|
||||
|
||||
Since CloudSticks auto-deploys from GitHub, you only need to set up the database config and ensure the server is running.
|
||||
|
||||
### Option 1: Use the CloudSticks Deployment Script
|
||||
|
||||
```bash
|
||||
cd /home/github2/apps/app-connect5
|
||||
chmod +x deploy-cloudsticks.sh
|
||||
./deploy-cloudsticks.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
- ✅ Install dependencies
|
||||
- ✅ Create `db.config.js` with Supabase credentials
|
||||
- ✅ Attempt to restart the server (systemd or PM2 if available)
|
||||
- ✅ Test the API endpoint
|
||||
|
||||
---
|
||||
|
||||
### Option 2: Manual Setup
|
||||
|
||||
If you prefer manual setup:
|
||||
|
||||
```bash
|
||||
cd /home/github2/apps/app-connect5
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Create db.config.js
|
||||
cat > db.config.js << 'EOF'
|
||||
module.exports = {
|
||||
supabaseUrl: 'https://wxtirlphaphwbrgsjyop.supabase.co',
|
||||
supabaseAnonKey: 'sb_publishable_Onh4nNYCV99d2eGidQIpqA_9PBkY8zs',
|
||||
supabasePassword: 't1hWsackxbYzRIPD',
|
||||
postgresConnectionString: 'postgresql://postgres:t1hWsackxbYzRIPD@db.wxtirlphaphwbrgsjyop.supabase.co:5432/postgres'
|
||||
};
|
||||
EOF
|
||||
|
||||
# Check if server is running
|
||||
ps aux | grep "node server.js"
|
||||
|
||||
# If not running, start it
|
||||
nohup node server.js > server.log 2>&1 &
|
||||
|
||||
# Or if CloudSticks uses systemd:
|
||||
sudo systemctl restart connect5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verify Deployment
|
||||
|
||||
### 1. Check if Node.js is Running
|
||||
|
||||
```bash
|
||||
ps aux | grep node
|
||||
```
|
||||
|
||||
Should show `node server.js` running
|
||||
|
||||
### 2. Test API Locally
|
||||
|
||||
```bash
|
||||
curl http://localhost:3000/api/db-status
|
||||
```
|
||||
|
||||
Should return JSON with `"connected": true`
|
||||
|
||||
### 3. Test in Browser
|
||||
|
||||
Visit: https://connect5.beyondcloud.technology/
|
||||
|
||||
Check status bar shows:
|
||||
- **SQL**: Connected ✅
|
||||
- **Latency**: ~45ms
|
||||
- **Write**: Enabled ✅
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Server Not Running
|
||||
|
||||
**Start the server**:
|
||||
```bash
|
||||
cd /home/github2/apps/app-connect5
|
||||
node server.js > server.log 2>&1 &
|
||||
```
|
||||
|
||||
**Check logs**:
|
||||
```bash
|
||||
tail -f server.log
|
||||
```
|
||||
|
||||
### API Returns 404
|
||||
|
||||
**Check Apache/Nginx proxy**:
|
||||
The web server needs to proxy `/api/*` and `/socket.io/*` to `localhost:3000`
|
||||
|
||||
**For Apache**, ensure you have:
|
||||
```apache
|
||||
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
|
||||
```
|
||||
|
||||
### Database Connection Fails
|
||||
|
||||
**Verify credentials**:
|
||||
```bash
|
||||
cat db.config.js
|
||||
```
|
||||
|
||||
**Test Supabase connection**:
|
||||
```bash
|
||||
node -e "const {supabase} = require('./database'); supabase.from('players').select('id').limit(1).then(console.log).catch(console.error)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CloudSticks-Specific Notes
|
||||
|
||||
- **Auto-Deploy**: CloudSticks automatically pulls from GitHub when you push
|
||||
- **No PM2**: CloudSticks may not have PM2 installed - use systemd or direct node
|
||||
- **Logs**: Check `server.log` for application logs
|
||||
- **Restart**: After code changes, restart the Node.js process
|
||||
|
||||
---
|
||||
|
||||
## Keep Server Running
|
||||
|
||||
### Option 1: Using nohup (Simple)
|
||||
```bash
|
||||
nohup node server.js > server.log 2>&1 &
|
||||
```
|
||||
|
||||
### Option 2: Using systemd (Recommended)
|
||||
|
||||
Create `/etc/systemd/system/connect5.service`:
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Connect-5 Multiplayer Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=github2
|
||||
WorkingDirectory=/home/github2/apps/app-connect5
|
||||
ExecStart=/usr/bin/node server.js
|
||||
Restart=always
|
||||
Environment=NODE_ENV=production
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Enable and start:
|
||||
```bash
|
||||
sudo systemctl enable connect5
|
||||
sudo systemctl start connect5
|
||||
sudo systemctl status connect5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Future Updates
|
||||
|
||||
When you push to GitHub:
|
||||
1. CloudSticks auto-deploys the code
|
||||
2. Run: `./deploy-cloudsticks.sh` (or restart server manually)
|
||||
3. Verify at https://connect5.beyondcloud.technology/
|
||||
123
deploy-cloudsticks.sh
Normal file
123
deploy-cloudsticks.sh
Normal file
@@ -0,0 +1,123 @@
|
||||
#!/bin/bash
|
||||
# CloudSticks Deployment Script for Connect-5
|
||||
# This version works without PM2 - uses systemd or direct node
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "🚀 Connect-5 CloudSticks Deployment"
|
||||
echo "===================================="
|
||||
echo ""
|
||||
|
||||
# Configuration
|
||||
PROJECT_DIR="/home/github2/apps/app-connect5"
|
||||
NODE_PORT=3000
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Step 1: Navigate to project directory
|
||||
echo "📁 Navigating to project directory..."
|
||||
cd "$PROJECT_DIR" || { echo -e "${RED}❌ Project directory not found!${NC}"; exit 1; }
|
||||
echo -e "${GREEN}✅ In directory: $(pwd)${NC}"
|
||||
echo ""
|
||||
|
||||
# Step 2: Install dependencies
|
||||
echo "📦 Installing dependencies..."
|
||||
npm install || { echo -e "${RED}❌ npm install failed!${NC}"; exit 1; }
|
||||
echo -e "${GREEN}✅ Dependencies installed${NC}"
|
||||
echo ""
|
||||
|
||||
# Step 3: Check if db.config.js exists
|
||||
echo "🔍 Checking for db.config.js..."
|
||||
if [ ! -f "db.config.js" ]; then
|
||||
echo -e "${YELLOW}⚠️ db.config.js not found!${NC}"
|
||||
echo "Creating db.config.js from template..."
|
||||
|
||||
cat > db.config.js << 'EOF'
|
||||
// Database Configuration File
|
||||
// IMPORTANT: This file contains sensitive credentials
|
||||
// DO NOT commit this file to git - it's in .gitignore
|
||||
|
||||
// Supabase Configuration
|
||||
module.exports = {
|
||||
supabaseUrl: 'https://wxtirlphaphwbrgsjyop.supabase.co',
|
||||
supabaseAnonKey: 'sb_publishable_Onh4nNYCV99d2eGidQIpqA_9PBkY8zs',
|
||||
supabasePassword: 't1hWsackxbYzRIPD',
|
||||
|
||||
// Optional: Direct PostgreSQL connection
|
||||
postgresConnectionString: 'postgresql://postgres:t1hWsackxbYzRIPD@db.wxtirlphaphwbrgsjyop.supabase.co:5432/postgres'
|
||||
};
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ db.config.js created${NC}"
|
||||
else
|
||||
echo -e "${GREEN}✅ db.config.js already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Step 4: Check how to restart the server
|
||||
echo "🔄 Checking server management..."
|
||||
|
||||
# Check if systemd service exists
|
||||
if systemctl list-units --type=service --all | grep -q "connect5.service"; then
|
||||
echo "Found systemd service, restarting..."
|
||||
sudo systemctl restart connect5
|
||||
echo -e "${GREEN}✅ Server restarted via systemd${NC}"
|
||||
|
||||
elif command -v pm2 &> /dev/null; then
|
||||
echo "Found PM2, restarting..."
|
||||
pm2 restart connect5 || pm2 start server.js --name connect5
|
||||
pm2 save
|
||||
echo -e "${GREEN}✅ Server restarted via PM2${NC}"
|
||||
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ No process manager found${NC}"
|
||||
echo "Please restart your Node.js server manually:"
|
||||
echo " Option 1: If using systemd: sudo systemctl restart connect5"
|
||||
echo " Option 2: If using PM2: pm2 restart connect5"
|
||||
echo " Option 3: Kill existing node process and start new one"
|
||||
echo ""
|
||||
echo "To start the server manually:"
|
||||
echo " cd $PROJECT_DIR"
|
||||
echo " node server.js &"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Step 5: Test API endpoint (if server is running)
|
||||
echo "🧪 Testing API endpoint..."
|
||||
sleep 3 # Give server time to start
|
||||
|
||||
API_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$NODE_PORT/api/db-status 2>/dev/null || echo "000")
|
||||
|
||||
if [ "$API_RESPONSE" = "200" ]; then
|
||||
echo -e "${GREEN}✅ API endpoint responding (HTTP $API_RESPONSE)${NC}"
|
||||
|
||||
# Get actual status
|
||||
echo ""
|
||||
echo "📊 Database Status:"
|
||||
curl -s http://localhost:$NODE_PORT/api/db-status | python3 -m json.tool 2>/dev/null || echo "Could not parse JSON"
|
||||
|
||||
elif [ "$API_RESPONSE" = "000" ]; then
|
||||
echo -e "${YELLOW}⚠️ Could not connect to server${NC}"
|
||||
echo "The server might not be running yet."
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ API endpoint returned HTTP $API_RESPONSE${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Final instructions
|
||||
echo "===================================="
|
||||
echo -e "${GREEN}🎉 Deployment Steps Complete!${NC}"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Ensure Node.js server is running"
|
||||
echo "2. Visit https://connect5.beyondcloud.technology/"
|
||||
echo "3. Check the status bar shows 'Connected'"
|
||||
echo ""
|
||||
echo "If server is not running, start it with:"
|
||||
echo " cd $PROJECT_DIR"
|
||||
echo " node server.js > server.log 2>&1 &"
|
||||
echo "===================================="
|
||||
Reference in New Issue
Block a user