Move monkey patch command in web UI and add dynamic threading

This commit is contained in:
Théophile Diot 2024-01-04 14:08:59 +00:00
parent ff7cb04c31
commit cff05457d1
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 13 additions and 6 deletions

View file

@ -1,5 +1,16 @@
from os import sep
from os import cpu_count, getenv, sep
from os.path import join
from sys import path as sys_path
deps_path = join(sep, "usr", "share", "bunkerweb", "deps", "python")
if deps_path not in sys_path:
sys_path.append(deps_path)
from gevent import monkey
monkey.patch_all()
MAX_THREADS = int(getenv("MAX_THREADS", max((cpu_count() or 1) - 1, 1)) * 2)
wsgi_app = "main:app"
accesslog = "/var/log/bunkerweb/ui-access.log"
@ -12,7 +23,7 @@ pidfile = join(sep, "var", "run", "bunkerweb", "ui.pid")
worker_tmp_dir = join(sep, "dev", "shm")
tmp_upload_dir = join(sep, "var", "tmp", "bunkerweb", "ui")
worker_class = "gevent"
threads = 1
threads = MAX_THREADS
workers = 1
graceful_timeout = 0
secure_scheme_headers = {}

View file

@ -12,10 +12,6 @@ for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in ((
if deps_path not in sys_path:
sys_path.append(deps_path)
from gevent import monkey
monkey.patch_all()
from bs4 import BeautifulSoup
from copy import deepcopy
from datetime import datetime, timedelta, timezone