feat: Phase 3 Tasks 16-18 — Pydantic-Settings, Error-Handler, systemd
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
WHATSAPP_APP_SECRET=dein_s...te
|
||||
@@ -0,0 +1,83 @@
|
||||
# BSN-Livesystem — Deploy-Anleitung
|
||||
|
||||
Installation des BSN-Livesystems als systemd-Dienste.
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- Ubuntu/Debian Server mit systemd
|
||||
- Python 3.12+
|
||||
- Redis-Server (lokal oder remote)
|
||||
- Git
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Repository klonen
|
||||
|
||||
```bash
|
||||
git clone git@git.datenhimmel.work:danielkrause/BSN-Livesystem.git /opt/bsn-livesystem
|
||||
cd /opt/bsn-livesystem
|
||||
```
|
||||
|
||||
### 2. Virtual Environment erstellen
|
||||
|
||||
```bash
|
||||
python3 -m venv venv
|
||||
./venv/bin/pip install --upgrade pip
|
||||
./venv/bin/pip install -e .
|
||||
```
|
||||
|
||||
### 3. Umgebungsvariablen konfigurieren
|
||||
|
||||
```bash
|
||||
cp .env .env.production
|
||||
# .env.production mit echten Werten bearbeiten:
|
||||
# - REDIS_HOST=...
|
||||
# - WHATSAPP_APP_SECRET=...
|
||||
# - TELEGRAM_BOT_TOKEN=...
|
||||
```
|
||||
|
||||
### 4. Services installieren
|
||||
|
||||
```bash
|
||||
sudo cp deploy/bsn-chatbot.service /etc/systemd/system/
|
||||
sudo cp deploy/bsn-worker.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
### 5. Services starten und aktivieren
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now bsn-chatbot
|
||||
sudo systemctl enable --now bsn-worker
|
||||
```
|
||||
|
||||
### 6. Status prüfen
|
||||
|
||||
```bash
|
||||
sudo systemctl status bsn-chatbot
|
||||
sudo systemctl status bsn-worker
|
||||
journalctl -u bsn-chatbot -f
|
||||
journalctl -u bsn-worker -f
|
||||
```
|
||||
|
||||
## Services aktualisieren
|
||||
|
||||
```bash
|
||||
cd /opt/bsn-livesystem
|
||||
git pull
|
||||
./venv/bin/pip install -e .
|
||||
sudo systemctl restart bsn-chatbot bsn-worker
|
||||
```
|
||||
|
||||
## Health-Check
|
||||
|
||||
```bash
|
||||
curl http://localhost:5002/health
|
||||
```
|
||||
|
||||
## Logs
|
||||
|
||||
```bash
|
||||
journalctl -u bsn-chatbot --since "1 hour ago"
|
||||
journalctl -u bsn-worker --since "1 hour ago"
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=BSN-Livesystem – Flask Chatbot Server
|
||||
After=network.target redis.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=bsn
|
||||
Group=bsn
|
||||
WorkingDirectory=/opt/bsn-livesystem
|
||||
ExecStart=/opt/bsn-livesystem/venv/bin/python -m src.app
|
||||
EnvironmentFile=/opt/bsn-livesystem/.env
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=BSN-Livesystem – Queue Worker Service
|
||||
After=network.target redis.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=bsn
|
||||
Group=bsn
|
||||
WorkingDirectory=/opt/bsn-livesystem
|
||||
ExecStart=/opt/bsn-livesystem/venv/bin/python -m src.queue.worker_entry
|
||||
EnvironmentFile=/opt/bsn-livesystem/.env
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user