mirror of
https://github.com/DeNNiiInc/Advanced-Raid-Calculator.git
synced 2026-04-17 12:45:59 +00:00
refactor: align deployment with proxmox template
This commit is contained in:
36
deploy.sh
36
deploy.sh
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user