Allow web UI to use multiple workers

This commit is contained in:
Théophile Diot 2024-01-04 15:08:12 +00:00
parent 309c5d0fe9
commit 676afd4c18
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 5 additions and 11 deletions

View file

@ -10,7 +10,7 @@ from gevent import monkey
monkey.patch_all()
MAX_THREADS = int(getenv("MAX_THREADS", max((cpu_count() or 1) - 1, 1)) * 2)
MAX_WORKERS = int(getenv("MAX_WORKERS", max((cpu_count() or 1) - 1, 1)))
wsgi_app = "main:app"
accesslog = "/var/log/bunkerweb/ui-access.log"
@ -22,8 +22,8 @@ reuse_port = True
pidfile = join(sep, "var", "run", "bunkerweb", "ui.pid")
worker_tmp_dir = join(sep, "dev", "shm")
tmp_upload_dir = join(sep, "var", "tmp", "bunkerweb", "ui")
workers = MAX_WORKERS
worker_class = "gevent"
threads = MAX_THREADS
workers = 1
threads = int(getenv("MAX_THREADS", MAX_WORKERS * 2))
graceful_timeout = 0
secure_scheme_headers = {}

View file

@ -80,13 +80,8 @@ signal(SIGTERM, handle_stop)
sbin_nginx_path = Path(sep, "usr", "sbin", "nginx")
# Flask app
app = Flask(
__name__,
static_url_path="/",
static_folder="static",
template_folder="templates",
)
app.secret_key = getenv("FLASK_SECRET", urandom(32))
app = Flask(__name__, static_url_path="/", static_folder="static", template_folder="templates")
app.config["SECRET_KEY"] = getenv("FLASK_SECRET", urandom(32))
PROXY_NUMBERS = int(getenv("PROXY_NUMBERS", "1"))
app.wsgi_app = ReverseProxied(app.wsgi_app, x_for=PROXY_NUMBERS, x_proto=PROXY_NUMBERS, x_host=PROXY_NUMBERS, x_prefix=PROXY_NUMBERS)
@ -188,7 +183,6 @@ bw_version = Path(sep, "usr", "share", "bunkerweb", "VERSION").read_text(encodin
try:
app.config.update(
DEBUG=True,
SECRET_KEY=getenv("FLASK_SECRET", urandom(32)),
INSTANCES=Instances(docker_client, kubernetes_client, INTEGRATION),
CONFIG=Config(db),
CONFIGFILES=ConfigFiles(app.logger, db),