Optimierung der PM2-Instanzverwaltung: Entfernen der zweiten Instanz und Anpassung der Fehlermeldungen in den Deployment-Skripten
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 10m23s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m52s

This commit is contained in:
Torsten Schulz (local)
2026-08-26 11:23:48 +02:00
parent c1c648de74
commit e82c1d9b0a
4 changed files with 17 additions and 46 deletions

View File

@@ -282,17 +282,11 @@ install_dependencies_if_needed
# 4. Stop running apps before replacing build artifacts
echo ""
echo "4. Stopping PM2 before replacing build artifacts..."
if command -v pm2 >/dev/null 2>&1; then
for instance_name in harheimertc harheimertc-3102; do
if pm2 describe "$instance_name" >/dev/null 2>&1; then
pm2 stop "$instance_name" || true
echo "$instance_name gestoppt"
else
echo " PM2-Prozess $instance_name läuft nicht"
fi
done
if command -v pm2 >/dev/null 2>&1 && pm2 describe harheimertc >/dev/null 2>&1; then
pm2 stop harheimertc || true
echo " ✓ harheimertc gestoppt"
else
echo " PM2 ist nicht verfügbar"
echo " PM2-Prozess harheimertc läuft nicht oder PM2 ist nicht verfügbar"
fi
# 5. Remove old build (but keep data!)
@@ -559,18 +553,14 @@ restart_pm2_instance() {
fi
}
# Starte/Neustarte beide Instanzen
# Starte/Neustarte die Produktionsinstanz
INSTANCE_ERRORS=0
if ! restart_pm2_instance "harheimertc"; then
INSTANCE_ERRORS=$((INSTANCE_ERRORS + 1))
fi
if ! restart_pm2_instance "harheimertc-3102"; then
INSTANCE_ERRORS=$((INSTANCE_ERRORS + 1))
fi
# Prüfe, ob beide Prozesse laufen
# Prüfe, ob der Prozess läuft
sleep 2
echo ""
echo " Checking PM2 instances status..."
@@ -582,19 +572,11 @@ else
INSTANCE_ERRORS=$((INSTANCE_ERRORS + 1))
fi
if pm2 describe harheimertc-3102 | grep -q "online"; then
echo " ✓ PM2-Prozess 'harheimertc-3102' läuft (online)"
else
echo " WARNING: PM2-Prozess 'harheimertc-3102' ist nicht online. Prüfe Logs: pm2 logs harheimertc-3102"
INSTANCE_ERRORS=$((INSTANCE_ERRORS + 1))
fi
if [ "$INSTANCE_ERRORS" -gt 0 ]; then
echo ""
echo "WARNING: Einige PM2-Instanzen haben Probleme. Bitte manuell prüfen:"
echo " pm2 status"
echo " pm2 logs harheimertc"
echo " pm2 logs harheimertc-3102"
fi
echo ""
@@ -603,8 +585,5 @@ echo "The application is now running with the latest code and your production da
echo ""
echo "Useful commands:"
echo " pm2 logs harheimertc # View logs (Port 3100)"
echo " pm2 logs harheimertc-3102 # View logs (Port 3102)"
echo " pm2 status # View status"
echo " pm2 restart harheimertc # Restart instance on port 3100"
echo " pm2 restart harheimertc-3102 # Restart instance on port 3102"
echo " pm2 restart all # Restart all instances"

View File

@@ -567,9 +567,10 @@ restart_pm2_instance() {
# Starte/Neustarte Test-Instanz
if ! restart_pm2_instance "harheimertc.test"; then
echo ""
echo "WARNING: PM2-Instanz konnte nicht gestartet werden. Bitte manuell prüfen:"
echo "ERROR: PM2-Instanz konnte nicht gestartet werden."
echo " pm2 status"
echo " pm2 logs harheimertc.test"
exit 1
fi
# Prüfe, ob der Prozess läuft
@@ -580,9 +581,16 @@ echo " Checking PM2 instance status..."
if pm2 describe harheimertc.test | grep -q "online"; then
echo " ✓ PM2-Prozess 'harheimertc.test' läuft (online)"
else
echo " WARNING: PM2-Prozess 'harheimertc.test' ist nicht online. Prüfe Logs: pm2 logs harheimertc.test"
echo " ERROR: PM2-Prozess 'harheimertc.test' ist nicht online. Prüfe Logs: pm2 logs harheimertc.test"
exit 1
fi
if ! curl --fail --silent --show-error --max-time 15 http://127.0.0.1:3102/ >/dev/null; then
echo "ERROR: Test-Instanz antwortet nicht auf Port 3102."
exit 1
fi
echo " ✓ HTTP-Healthcheck auf Port 3102 erfolgreich"
echo ""
echo "=== Test-Instanz Deployment completed successfully! ==="
echo "The test application is now running with the latest code and your test data preserved."

View File

@@ -61,22 +61,6 @@ module.exports = {
out_file: '/var/log/pm2/harheimertc-out.log',
log_file: '/var/log/pm2/harheimertc-combined.log',
time: true
},
{
name: 'harheimertc-3102',
// Zweite Instanz auf Port 3102
script: 'node',
args: '.output/server/index.mjs',
cwd: '/var/www/harheimertc',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: createEnv(3102),
error_file: '/var/log/pm2/harheimertc-3102-error.log',
out_file: '/var/log/pm2/harheimertc-3102-out.log',
log_file: '/var/log/pm2/harheimertc-3102-combined.log',
time: true
}
]
}

View File

@@ -58,7 +58,7 @@ module.exports = {
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: createEnv(process.env.PORT || 3102),
env: createEnv(3102),
error_file: '/var/log/pm2/harheimertc.test-error.log',
out_file: '/var/log/pm2/harheimertc.test-out.log',
log_file: '/var/log/pm2/harheimertc.test-combined.log',