Add deployment scripts and update proxy config

This commit is contained in:
2025-12-27 16:20:14 +11:00
parent 865eacc971
commit dbc8aeeab9
8 changed files with 982 additions and 414 deletions

35
auto-sync.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# auto-sync.sh - Run by Cron every 5 minutes
APP_DIR="/var/www/website-stress-test"
APP_NAME="website-stress-test"
cd "$APP_DIR" || exit
echo "[$(date)] Checking for updates..."
# Fetch latest changes
git remote update
# Check if we are behind
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
if [ "$LOCAL" = "$REMOTE" ]; then
echo "Up-to-date."
elif [ "$LOCAL" = "$BASE" ]; then
echo "Update available using git pull."
git pull
echo "Installing dependencies..."
npm install
echo "Restarting PM2 process..."
pm2 restart "$APP_NAME"
echo "✅ Updated and restarted."
elif [ "$REMOTE" = "$BASE" ]; then
echo "Need to push"
else
echo "Diverged"
fi