Diese Seite ist in Ihrer Sprache noch nicht verfügbar. Englische Version wird angezeigt.
Produktionseinrichtung
Potato für Produktionsannotation mit mehreren Benutzern bereitstellen.
Produktionseinrichtung
Stellen Sie Potato für reale Annotationsaufgaben mit mehreren Benutzern, Datenpersistenz und angemessener Sicherheit bereit.
Serverkonfiguration
Grundlegende Produktionskonfiguration
yaml
server:
host: 0.0.0.0
port: 8000
workers: 4
timeout: 120HTTPS verwenden
Für sichere Verbindungen (für Produktion empfohlen):
yaml
server:
host: 0.0.0.0
port: 443
ssl:
cert: /path/to/cert.pem
key: /path/to/key.pemMit Gunicorn ausführen
Für bessere Leistung und Zuverlässigkeit:
bash
gunicorn "potato.server:create_app('config.yaml')" \
--workers 4 \
--bind 0.0.0.0:8000 \
--timeout 120Mit SSL
bash
gunicorn "potato.server:create_app('config.yaml')" \
--workers 4 \
--bind 0.0.0.0:443 \
--certfile /path/to/cert.pem \
--keyfile /path/to/key.pemReverse Proxy einrichten
Nginx-Konfiguration
nginx
upstream potato {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name annotation.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name annotation.example.com;
ssl_certificate /etc/letsencrypt/live/annotation.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/annotation.example.com/privkey.pem;
location / {
proxy_pass http://potato;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Increase timeouts for long annotation sessions
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
}Apache-Konfiguration
apache
<VirtualHost *:443>
ServerName annotation.example.com
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>Docker-Bereitstellung
Dockerfile
dockerfile
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["gunicorn", "potato.server:create_app('config.yaml')", \
"--workers", "4", "--bind", "0.0.0.0:8000"]Docker Compose
yaml
version: '3.8'
services:
potato:
build: .
ports:
- "8000:8000"
volumes:
- ./data:/app/data
- ./annotations:/app/annotations
environment:
- POTATO_DEBUG=false
restart: unless-stopped
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./certs:/etc/ssl/certs
depends_on:
- potato
restart: unless-stoppedBenutzerauthentifizierung
Eingeschränkter Zugriff
yaml
allow_all_users: false
authorized_users:
- user1@example.com
- user2@example.com
- user3@example.comAdmin-Zugriff
yaml
admin_users:
- admin@example.com
admin_dashboard:
enabled: true
path: /adminSitzungsverwaltung
yaml
session:
secret_key: "your-secure-secret-key-here"
timeout: 3600 # 1 hour
secure_cookie: true # Requires HTTPSDatenpersistenz
Dateibasierte Speicherung
yaml
output:
path: /var/potato/annotations/
format: json
backup_interval: 3600 # Hourly backupsDatenbank-Backend
Für größere Deployments, MySQL verwenden:
yaml
database:
type: mysql
host: localhost
port: 3306
name: potato_db
user: potato
password: ${DB_PASSWORD} # Use environment variableDetails finden Sie unter MySQL Backend.
Überwachung
Health-Check-Endpunkt
yaml
monitoring:
health_check: /health
metrics: /metricsProtokollierungskonfiguration
yaml
logging:
level: INFO
file: /var/log/potato/app.log
max_size: 100MB
backup_count: 5
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"Prometheus-Metriken
yaml
monitoring:
prometheus:
enabled: true
port: 9090Skalierung
Horizontale Skalierung
Für Deployments mit hohem Datenverkehr:
yaml
# docker-compose.yml
services:
potato:
deploy:
replicas: 3
# ... rest of config
nginx:
# Load balancer
volumes:
- ./nginx-lb.conf:/etc/nginx/nginx.confLoad-Balancer-Konfiguration
nginx
upstream potato_cluster {
least_conn;
server potato_1:8000;
server potato_2:8000;
server potato_3:8000;
}Backup-Strategie
Automatisierte Backups
bash
#!/bin/bash
# backup.sh
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR=/var/backups/potato
# Backup annotations
tar -czf $BACKUP_DIR/annotations_$DATE.tar.gz /var/potato/annotations/
# Backup config
cp /var/potato/config.yaml $BACKUP_DIR/config_$DATE.yaml
# Keep only last 7 days
find $BACKUP_DIR -mtime +7 -deleteZur Crontab hinzufügen:
bash
0 2 * * * /var/potato/backup.shSicherheits-Checkliste
- HTTPS mit gültigem SSL-Zertifikat verwenden
- Starken Sitzungs-Schlüssel setzen
- Benutzerzugriff mit
authorized_userseinschränken - Potato und Abhängigkeiten aktuell halten
- Umgebungsvariablen für sensible Daten verwenden
- Firewall-Regeln konfigurieren
- Protokollierung und Überwachung aktivieren
- Regelmäßige Backups einrichten
- Datenbank-Backend für Produktion verwenden
- Admin-Zugriff regelmäßig überprüfen
Umgebungsvariablen
bash
# .env file
POTATO_SECRET_KEY=your-super-secret-key
POTATO_DB_PASSWORD=database-password
POTATO_ADMIN_EMAIL=admin@example.comIn Docker Compose laden:
yaml
services:
potato:
env_file:
- .envFehlerbehebung
Protokolle prüfen
bash
# Gunicorn logs
journalctl -u potato -f
# Docker logs
docker-compose logs -f potatoHäufige Probleme
502 Bad Gateway: Prüfen Sie, ob Potato läuft und an den richtigen Port gebunden ist
Sitzungsprobleme: Stellen Sie sicher, dass der geheime Schlüssel bei Neustarts konsistent ist
Langsame Leistung: Worker-Anzahl erhöhen oder Datenbank-Backend hinzufügen
Nächste Schritte
- MySQL Backend - Datenbankspeicher
- Crowdsourcing - Prolific/MTurk-Integration
- User Management - Zugriffskontrolle