# 🔧 Backend Services (systemd) ## Problem gelöst: Backends sind nach Server-Neustart oder Crash abgestürzt. ## Lösung: Systemd Services erstellt - Backends starten automatisch! --- ## 📋 Services: ### **Dev-Backend:** - **Service:** `pfandsystem-dev-backend.service` - **Port:** 3001 - **Verzeichnis:** `/root/entwicklung/pfandsystem/backend` - **Log:** `/var/log/pfandsystem-dev-backend.log` ### **Live-Backend (BorBäcker):** - **Service:** `borbaecker-backend.service` - **Port:** 3002 - **Verzeichnis:** `/root/livesysteme/borbaecker/backend` - **Log:** `/var/log/borbaecker-backend.log` --- ## 🎯 Befehle: ### **Status prüfen:** ```bash systemctl status pfandsystem-dev-backend systemctl status borbaecker-backend ``` ### **Starten:** ```bash systemctl start pfandsystem-dev-backend systemctl start borbaecker-backend ``` ### **Stoppen:** ```bash systemctl stop pfandsystem-dev-backend systemctl stop borbaecker-backend ``` ### **Neu starten:** ```bash systemctl restart pfandsystem-dev-backend systemctl restart borbaecker-backend ``` ### **Logs ansehen:** ```bash tail -f /var/log/pfandsystem-dev-backend.log tail -f /var/log/borbaecker-backend.log # Oder mit journalctl: journalctl -u pfandsystem-dev-backend -f journalctl -u borbaecker-backend -f ``` ### **Autostart deaktivieren:** ```bash systemctl disable pfandsystem-dev-backend systemctl disable borbaecker-backend ``` --- ## ✅ Features: - **Automatischer Start** beim Server-Neustart - **Automatischer Neustart** bei Crash (nach 10 Sekunden) - **Logging** in separate Dateien - **Systemd-Integration** - Standard Linux Service Management --- ## 🔄 Nach Code-Änderungen: ```bash # Backend neu starten systemctl restart borbaecker-backend # Oder manuell (wenn Service gestoppt werden soll): systemctl stop borbaecker-backend cd /root/livesysteme/borbaecker/backend npm start ``` --- ## 🧪 Test: ```bash # Backends testen curl http://localhost:3001/health curl http://localhost:3002/health # Login testen curl -X POST http://localhost:3002/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"admin@pfandsystem.de","password":"admin123"}' ``` --- ## 📊 Monitoring: ```bash # Beide Services überwachen watch -n 2 'systemctl status pfandsystem-dev-backend borbaecker-backend' # Logs live verfolgen tail -f /var/log/pfandsystem-dev-backend.log /var/log/borbaecker-backend.log ``` --- **Backends laufen jetzt als systemd Services und starten automatisch!** 🚀