228 lines
5.7 KiB
Markdown
228 lines
5.7 KiB
Markdown
# MYP Installer - Python 3.11 Service Update
|
|
|
|
## Übersicht der Änderungen
|
|
|
|
Das `myp_installer.sh` Skript wurde aktualisiert, um sicherzustellen, dass alle Services explizit Python 3.11 verwenden und alte Services ordnungsgemäß entfernt werden.
|
|
|
|
## Wichtige Änderungen
|
|
|
|
### 1. Neue Funktionen hinzugefügt
|
|
|
|
#### `remove_old_services()`
|
|
|
|
- Entfernt systematisch alte MYP Services
|
|
- Unterstützt Backend-, Kiosk- und alle Services
|
|
- Stoppt und deaktiviert Services sicher
|
|
- Services: `myp.service`, `myp-platform.service`, `myp-backend.service`, `myp-kiosk-browser.service`, etc.
|
|
|
|
#### `create_backend_service()`
|
|
|
|
- Erstellt neuen Backend-Service mit explizitem Python 3.11 Pfad
|
|
- Verwendet `python3.11` im ExecStart-Befehl
|
|
- Konfiguriert korrekte Umgebungsvariablen
|
|
- Setzt Sicherheitseinstellungen
|
|
|
|
#### `create_kiosk_service()`
|
|
|
|
- Erstellt Kiosk-Browser-Service
|
|
- Abhängig vom Backend-Service
|
|
- Wartet auf Backend-Verfügbarkeit vor Start
|
|
|
|
#### `manage_services()`
|
|
|
|
- Vollständiges Service-Management-Interface
|
|
- Start, Stopp, Neustart, Status, Logs
|
|
- Aktivierung/Deaktivierung von Services
|
|
|
|
#### `show_logs()`
|
|
|
|
- Umfassendes Log-Anzeige-System
|
|
- Systemd-Logs und Application-Logs
|
|
- Live-Modus und Fehler-Logs
|
|
|
|
### 2. Service-Konfiguration aktualisiert
|
|
|
|
#### Backend Service (`myp.service`)
|
|
|
|
```ini
|
|
[Unit]
|
|
Description=MYP Reservation Platform Backend (Python 3.11)
|
|
After=network.target
|
|
Wants=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=$USER
|
|
Group=$USER
|
|
WorkingDirectory=$PROJECT_DIR/backend/app
|
|
Environment=PYTHONPATH=$PROJECT_DIR/backend/app
|
|
Environment=FLASK_ENV=production
|
|
Environment=FLASK_APP=app.py
|
|
Environment=PYTHONUNBUFFERED=1
|
|
ExecStart=$PROJECT_DIR/backend/venv/bin/python3.11 app.py --host 0.0.0.0 --port 443 --cert certs/backend.crt --key certs/backend.key
|
|
Restart=always
|
|
RestartSec=10
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
SyslogIdentifier=myp-backend
|
|
|
|
# Security settings
|
|
NoNewPrivileges=true
|
|
PrivateTmp=true
|
|
ProtectSystem=strict
|
|
ProtectHome=true
|
|
ReadWritePaths=$PROJECT_DIR/backend/app/logs
|
|
ReadWritePaths=$PROJECT_DIR/backend/app/database
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
#### Kiosk Service (`myp-kiosk-browser.service`)
|
|
|
|
```ini
|
|
[Unit]
|
|
Description=MYP Kiosk Browser - 3D Printer Management Kiosk Interface (Python 3.11 Backend)
|
|
After=network.target graphical-session.target myp.service
|
|
Requires=myp.service
|
|
PartOf=myp.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=$USER
|
|
Group=$USER
|
|
Environment=DISPLAY=:0
|
|
Environment=XAUTHORITY=/home/$USER/.Xauthority
|
|
ExecStartPre=/bin/bash -c 'until curl -k -s https://localhost:443/ > /dev/null; do sleep 2; done'
|
|
ExecStart=/usr/bin/chromium-browser --kiosk --disable-infobars --disable-session-crashed-bubble --disable-translate --no-first-run --disable-features=VizDisplayCompositor --start-fullscreen --autoplay-policy=no-user-gesture-required https://localhost:443/
|
|
Restart=always
|
|
RestartSec=10
|
|
KillMode=mixed
|
|
TimeoutStopSec=30
|
|
|
|
[Install]
|
|
WantedBy=graphical-session.target
|
|
```
|
|
|
|
### 3. Virtual Environment Verbesserungen
|
|
|
|
- Explizite Erstellung mit `python3.11 -m venv`
|
|
- Prüfung ob existierendes venv Python 3.11 verwendet
|
|
- Automatische Neuerstellung falls falsche Python-Version
|
|
|
|
### 4. Installationsprozess optimiert
|
|
|
|
#### Backend Installation (`install_backend()`)
|
|
|
|
1. Python 3.11 Verfügbarkeit prüfen
|
|
2. Virtual Environment mit Python 3.11 erstellen/prüfen
|
|
3. Dependencies installieren
|
|
4. Verzeichnisse erstellen
|
|
5. Datenbank mit Python 3.11 initialisieren
|
|
6. SSL-Zertifikate erstellen
|
|
7. Alte Services entfernen
|
|
8. Neuen Backend-Service erstellen
|
|
9. Kiosk-Konfiguration (optional)
|
|
|
|
#### Produktions-Installation (`install_production_backend()`)
|
|
|
|
1. Python 3.11 Virtual Environment
|
|
2. Requirements installieren
|
|
3. Zertifikate kopieren
|
|
4. Alte Services entfernen
|
|
5. Neuen Service mit Python 3.11 erstellen
|
|
6. Datenbank mit Python 3.11 initialisieren
|
|
7. Kiosk-Konfiguration
|
|
8. Kiosk-Service erstellen
|
|
|
|
### 5. Service-Dateien aktualisiert
|
|
|
|
#### `backend/myp.service`
|
|
|
|
- ExecStart verwendet jetzt `python3.11`
|
|
- PYTHONUNBUFFERED=1 hinzugefügt
|
|
- Beschreibung aktualisiert
|
|
|
|
#### `backend/install/myp.service`
|
|
|
|
- ExecStart verwendet jetzt `python3.11`
|
|
- Beschreibung aktualisiert
|
|
|
|
## Verwendung
|
|
|
|
### Neue Installation
|
|
|
|
```bash
|
|
./myp_installer.sh
|
|
# Wähle Option für Backend-Installation
|
|
# Services werden automatisch mit Python 3.11 konfiguriert
|
|
```
|
|
|
|
### Service-Management
|
|
|
|
```bash
|
|
./myp_installer.sh
|
|
# Wähle Option 13: "Services verwalten"
|
|
# Vollständiges Service-Management verfügbar
|
|
```
|
|
|
|
### Log-Anzeige
|
|
|
|
```bash
|
|
./myp_installer.sh
|
|
# Wähle Option 12: "Logs anzeigen"
|
|
# Verschiedene Log-Optionen verfügbar
|
|
```
|
|
|
|
## Vorteile
|
|
|
|
1. **Konsistenz**: Alle Services verwenden explizit Python 3.11
|
|
2. **Sauberkeit**: Alte Services werden ordnungsgemäß entfernt
|
|
3. **Sicherheit**: Moderne systemd Security-Features aktiviert
|
|
4. **Wartbarkeit**: Zentrale Service-Management-Funktionen
|
|
5. **Debugging**: Umfassendes Logging-System
|
|
6. **Automatisierung**: Vollständig automatisierte Installation
|
|
|
|
## Kompatibilität
|
|
|
|
- Funktioniert mit bestehenden Installationen
|
|
- Entfernt automatisch alte/inkompatible Services
|
|
- Behält Datenbank und Konfiguration bei
|
|
- Unterstützt sowohl Entwicklungs- als auch Produktionsumgebungen
|
|
|
|
## Fehlerbehebung
|
|
|
|
### Service startet nicht
|
|
|
|
```bash
|
|
# Status prüfen
|
|
systemctl status myp.service
|
|
|
|
# Logs anzeigen
|
|
journalctl -u myp.service -f
|
|
|
|
# Python 3.11 verfügbar?
|
|
which python3.11
|
|
python3.11 --version
|
|
```
|
|
|
|
### Virtual Environment Probleme
|
|
|
|
```bash
|
|
# Virtual Environment neu erstellen
|
|
rm -rf backend/venv
|
|
python3.11 -m venv backend/venv
|
|
source backend/venv/bin/activate
|
|
pip install -r backend/requirements.txt
|
|
```
|
|
|
|
### Alte Services entfernen
|
|
|
|
```bash
|
|
# Manuell alte Services entfernen
|
|
sudo systemctl stop myp-platform.service
|
|
sudo systemctl disable myp-platform.service
|
|
sudo rm /etc/systemd/system/myp-platform.service
|
|
sudo systemctl daemon-reload
|
|
```
|