3.3 KiB
3.3 KiB
Services überprüfen und verwalten
Backend-Service Status prüfen
Das Deploy-Script verwendet PM2 als Standard. Hier die Befehle:
Mit PM2 (Standard)
# Status anzeigen
pm2 status
# Detaillierte Info
pm2 info timeclock-backend
# Ist der Service laufend?
pm2 list | grep timeclock-backend
# Logs ansehen
pm2 logs timeclock-backend
# Letzten 50 Zeilen
pm2 logs timeclock-backend --lines 50
Backend manuell starten (falls nicht laufend)
cd /var/www/timeclock/backend
pm2 start src/index.js --name timeclock-backend --env production
pm2 save
Mit systemd (falls PM2 nicht verwendet)
# Status prüfen
sudo systemctl status timeclock
# Ist der Service aktiv?
systemctl is-active timeclock
# Logs ansehen
sudo journalctl -u timeclock -f
Alle Services überprüfen
Kompletter Status-Check
# Backend (PM2)
echo "=== Backend (PM2) ==="
pm2 status
# Apache2
echo ""
echo "=== Apache2 ==="
sudo systemctl status apache2 --no-pager | head -n 15
# Backend-Health-Check
echo ""
echo "=== Backend Health-Check ==="
curl -s http://localhost:3010/api/health | jq || curl http://localhost:3010/api/health
# Frontend erreichbar?
echo ""
echo "=== Frontend Check ==="
curl -I https://stechuhr3.tsschulz.de 2>/dev/null | head -n 5
Oder mit dem Deploy-Script
cd /var/www/timeclock
./deploy.sh status
Backend neu starten
Mit PM2
# Neustart
pm2 restart timeclock-backend
# Stoppen
pm2 stop timeclock-backend
# Starten
pm2 start timeclock-backend
# Löschen und neu starten
pm2 delete timeclock-backend
cd /var/www/timeclock/backend
pm2 start src/index.js --name timeclock-backend --env production
pm2 save
Mit systemd
sudo systemctl restart timeclock
sudo systemctl stop timeclock
sudo systemctl start timeclock
Troubleshooting
Backend läuft nicht
-
Prüfe Logs:
pm2 logs timeclock-backend --err -
Prüfe .env Datei:
cat /var/www/timeclock/backend/.env -
Prüfe Port-Belegung:
sudo netstat -tulpn | grep 3010 # oder sudo lsof -i :3010 -
Prüfe Datenbank-Verbindung:
mysql -h tsschulz.de -u stechuhr2 -p stechuhr2 -e "SHOW TABLES;" -
Manuell starten (Debug):
cd /var/www/timeclock/backend node src/index.js # Siehst du Fehler?
Backend startet, aber API antwortet nicht
-
Health-Check direkt:
curl http://localhost:3010/api/health -
Apache Proxy prüfen:
# Ist Proxy-Modul aktiv? apache2ctl -M | grep proxy # Apache Error-Log sudo tail -f /var/log/apache2/stechuhr3-error.log -
Firewall prüfen:
sudo ufw status
Monitoring einrichten
PM2 Monitoring
# Real-time Monitoring
pm2 monit
# Web-Dashboard (PM2 Plus)
pm2 plus
Automatischer Neustart bei Absturz
PM2 startet automatisch neu. Konfiguration:
pm2 startup systemd
# Führe den angezeigten Befehl aus
pm2 save
Health-Check Cronjob
Siehe scripts/health-check.sh für automatisches Monitoring!
Schnell-Befehle
# Alles prüfen
./deploy.sh status
# Logs live ansehen
./deploy.sh logs
# Backend neu starten
pm2 restart timeclock-backend
# Apache neu starten
sudo systemctl restart apache2