31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
"""Gunicorn-Konfiguration für den Projekt-Hub.
|
||
|
||
Aufruf (im aktivierten venv, WorkingDirectory = Projektordner):
|
||
gunicorn -c gunicorn.conf.py wsgi:app
|
||
|
||
Wird vom systemd-Service (deploy/projekt-hub.service) genutzt. Werte sind über
|
||
Umgebungsvariablen überschreibbar, sinnvolle Defaults für einen kleinen VPS.
|
||
"""
|
||
|
||
import multiprocessing
|
||
import os
|
||
|
||
# Bind-Adresse: standardmäßig ein Unix-Socket relativ zum WorkingDirectory.
|
||
# nginx spricht denselben Socket per absoluter Pfadangabe an
|
||
# (z.B. /home/projekthub/projekt-hub/projekt-hub.sock).
|
||
bind = os.environ.get("GUNICORN_BIND", "unix:projekt-hub.sock")
|
||
|
||
# Worker-Anzahl: Faustregel (2 × CPU-Kerne) + 1, per env begrenzbar.
|
||
workers = int(os.environ.get("GUNICORN_WORKERS", str(multiprocessing.cpu_count() * 2 + 1)))
|
||
worker_class = os.environ.get("GUNICORN_WORKER_CLASS", "sync")
|
||
timeout = int(os.environ.get("GUNICORN_TIMEOUT", "30"))
|
||
|
||
# Socket-Dateirechte, damit nginx (Gruppe www-data) zugreifen kann.
|
||
umask = 0o007
|
||
|
||
# Logs auf stdout/stderr → landen via systemd im journal (journalctl -u projekt-hub).
|
||
accesslog = "-"
|
||
errorlog = "-"
|
||
loglevel = os.environ.get("GUNICORN_LOGLEVEL", "info")
|
||
|
||
proc_name = "projekt-hub"
|