Enhance deployment script with PM2 process checks and error handling
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s
Update deploy-production.sh to include checks for PM2 installation and process existence before restarting. Implement error messages for failed starts and restarts, improving robustness and user guidance during deployment. Additionally, add useful commands for managing the PM2 process post-deployment.
This commit is contained in:
@@ -311,9 +311,50 @@ echo "7. Keeping backups in $BACKUP_ROOT (no git stash used)."
|
||||
# 8. Restart PM2
|
||||
echo ""
|
||||
echo "8. Restarting PM2..."
|
||||
pm2 restart harheimertc
|
||||
|
||||
# Prüfe, ob PM2 installiert ist
|
||||
if ! command -v pm2 &> /dev/null; then
|
||||
echo "ERROR: PM2 ist nicht installiert oder nicht im PATH!"
|
||||
echo "Bitte installieren Sie PM2: npm install -g pm2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prüfe, ob der Prozess existiert
|
||||
if ! pm2 describe harheimertc &> /dev/null; then
|
||||
echo "WARNING: PM2-Prozess 'harheimertc' existiert nicht."
|
||||
echo "Versuche, den Prozess zu starten..."
|
||||
pm2 start harheimertc.config.cjs || pm2 start harheimertc.simple.cjs || {
|
||||
echo "ERROR: Konnte PM2-Prozess nicht starten."
|
||||
echo "Bitte manuell starten: pm2 start harheimertc.config.cjs"
|
||||
exit 1
|
||||
}
|
||||
echo " ✓ PM2-Prozess gestartet"
|
||||
else
|
||||
# Restart mit --update-env, um Umgebungsvariablen zu aktualisieren
|
||||
echo " Restarting harheimertc with --update-env..."
|
||||
if pm2 restart harheimertc --update-env; then
|
||||
echo " ✓ PM2-Prozess neu gestartet"
|
||||
else
|
||||
echo "ERROR: PM2-Restart fehlgeschlagen!"
|
||||
echo "Bitte manuell prüfen: pm2 logs harheimertc"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Prüfe, ob der Prozess läuft
|
||||
sleep 2
|
||||
if pm2 describe harheimertc | grep -q "online"; then
|
||||
echo " ✓ PM2-Prozess läuft (online)"
|
||||
else
|
||||
echo "WARNING: PM2-Prozess ist nicht online. Prüfe Logs: pm2 logs harheimertc"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Deployment completed successfully! ==="
|
||||
echo "The application is now running with the latest code and your production data preserved."
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " pm2 logs harheimertc # View logs"
|
||||
echo " pm2 status # View status"
|
||||
echo " pm2 restart harheimertc # Restart manually"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user