Monorepo for Aesthetic.Computer aesthetic.computer
at main 56 lines 1.8 kB view raw
1#!/usr/bin/env fish 2# Deploy session server to production 3# This script pulls latest code, installs dependencies, and restarts the service 4 5set SERVER "root@157.245.134.225" 6set SSH_KEY "$HOME/.ssh/session_server" 7set REPO_PATH "/home/aesthetic-computer" 8 9echo "🚀 Deploying session server to production..." 10echo "" 11 12# Step 1: Pull latest code 13echo "📥 Step 1/4: Pulling latest code from GitHub..." 14ssh -i $SSH_KEY $SERVER "cd $REPO_PATH && git fetch origin && git reset --hard origin/main" 15 16if test $status -ne 0 17 echo "" 18 echo "❌ Failed to pull code from GitHub" 19 exit 1 20end 21 22# Step 2: Install dependencies (skip if node_modules exists) 23echo "" 24echo "📦 Step 2/4: Checking dependencies..." 25ssh -i $SSH_KEY $SERVER "cd $REPO_PATH/session-server && if [ ! -d node_modules ]; then echo 'Installing...'; npm install; else echo 'Dependencies already installed'; fi" 26 27if test $status -ne 0 28 echo "" 29 echo "❌ Failed to install dependencies" 30 exit 1 31end 32 33# Step 3: Restart service 34echo "" 35echo "🔄 Step 3/4: Restarting session server..." 36ssh -i $SSH_KEY $SERVER "pkill -f 'node.*session.mjs' && sleep 2 && cd $REPO_PATH/session-server && nohup node session.mjs > /tmp/session-server.log 2>&1 &" 37 38if test $status -ne 0 39 echo "" 40 echo "❌ Failed to restart session server" 41 exit 1 42end 43 44# Step 4: Show logs 45echo "" 46echo "📊 Step 4/4: Checking server status..." 47sleep 3 48ssh -i $SSH_KEY $SERVER "ps aux | grep 'session.mjs' | grep -v grep && echo '' && tail -20 /tmp/session-server.log" 49 50echo "" 51echo "✅ Deployment complete!" 52echo "" 53echo "📡 Test the endpoints:" 54echo " curl -k https://session-server.aesthetic.computer/build-stream \\" 55echo " --header 'Content-Type: application/json' \\" 56echo " --data '{\"line\": \"Test message\"}'"