Modify `deployment/check_frontend.sh` to source the `.env` file before starting the Node.js development server. This ensures that environment variables, such as `DATABASE_URL`, are properly loaded, resolving startup errors on non-Replit environments. Also updates `replit.md` to document this fix. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 21e2b3ab-3e67-45ff-819b-a2db15c27292 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/dI1I79r
41 lines
1.0 KiB
Bash
41 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# =========================================================
|
|
# CHECK FRONTEND - Verifica e riavvia frontend Node.js se necessario
|
|
# =========================================================
|
|
|
|
PROCESS_NAME="npm run dev"
|
|
PID_FILE="/var/log/ids/frontend.pid"
|
|
LOG_FILE="/var/log/ids/frontend.log"
|
|
WORK_DIR="/opt/ids"
|
|
|
|
mkdir -p /var/log/ids
|
|
|
|
# Check if frontend is running
|
|
if pgrep -f "vite" > /dev/null; then
|
|
# Frontend running, update PID
|
|
pgrep -f "vite" > "$PID_FILE"
|
|
exit 0
|
|
else
|
|
echo "[$(date)] Frontend Node NON attivo, riavvio..." >> "$LOG_FILE"
|
|
|
|
# Kill any orphaned Node processes
|
|
pkill -f "vite" 2>/dev/null
|
|
pkill -f "npm run dev" 2>/dev/null
|
|
|
|
# Wait a moment
|
|
sleep 2
|
|
|
|
# Load environment variables from .env file
|
|
set -a
|
|
source "$WORK_DIR/.env" 2>/dev/null || true
|
|
set +a
|
|
|
|
# Start frontend
|
|
cd "$WORK_DIR"
|
|
nohup npm run dev >> "$LOG_FILE" 2>&1 &
|
|
NEW_PID=$!
|
|
echo $NEW_PID > "$PID_FILE"
|
|
|
|
echo "[$(date)] Frontend riavviato con PID: $NEW_PID" >> "$LOG_FILE"
|
|
fi
|