refactor: align deployment with proxmox template

This commit is contained in:
2025-12-27 15:52:31 +11:00
parent 908a00b38c
commit bd40b7cd8c
6 changed files with 266 additions and 21 deletions

View File

@@ -3,30 +3,38 @@
# Ensure we are in the project directory
cd "$(dirname "$0")"
echo "Deploying Advanced Raid Calculator..."
APP_NAME="advanced-raid-calculator"
INSTALL_DIR="/var/www/$APP_NAME"
SERVICE_NAME="$APP_NAME.service"
echo "Deploying $APP_NAME..."
# Ensure install directory exists (if running for the first time outside of it, though git clone usually does this)
# If we are running this script FROM the repo, we assume we are already in the right place or we are setting it up.
# This script assumes it is being run inside the destination directory /var/www/advanced-raid-calculator
# Install dependencies
echo "Installing dependencies..."
npm install
# Restart the application using PM2
if command -v pm2 &> /dev/null; then
echo "Restarting with PM2..."
# Check if the process is already running
if pm2 list | grep -q "raid-calculator"; then
pm2 reload raid-calculator
else
pm2 start server.js --name "raid-calculator"
fi
pm2 save
# Setup Systemd Service
echo "Configuring Systemd Service..."
if [ -f "$SERVICE_NAME" ]; then
cp "$SERVICE_NAME" "/etc/systemd/system/$SERVICE_NAME"
systemctl daemon-reload
systemctl enable "$SERVICE_NAME"
systemctl restart "$SERVICE_NAME"
echo "Service restarted."
else
echo "PM2 not found. Please install PM2 globally (npm install -g pm2)."
# Fallback for testing without PM2, though PM2 is expected on the TurnKey template
# node server.js
echo "Error: $SERVICE_NAME not found!"
exit 1
fi
# Run the proxy setup script
chmod +x setup-proxy.sh
./setup-proxy.sh
# Fix permissions (ensure www-data owns the web dir)
chown -R www-data:www-data "$INSTALL_DIR"
echo "Deployment complete."