- Source-Copy von /root/entwicklung/pfandsystem - docker-compose.yml umgeschrieben: pfandsystem-demo-* Container, Ports 3308/8083/3003 (alle localhost) - Traefik-Label fuer pfandsystem.dockly.de - Erweitertes Multi-Tenant-Schema (tenants, tenant_id auf allen Tabellen) - Neue Tabellen: kunden_bilder, geraete - Neue Spalten: kunden.anlieferungshinweis, kunden.lieferzeit_bis - Rollen: superadmin, admin, user, fahrer - .env.example + README Code-Refactor (Tailwind, Multi-Tenant-Middleware, Erweiterungen) folgt.
122 lines
2.4 KiB
Markdown
122 lines
2.4 KiB
Markdown
# 🔧 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!** 🚀
|