diff --git a/src/ui/gunicorn.conf.py b/src/ui/gunicorn.conf.py index 278b02094..3efaa3582 100644 --- a/src/ui/gunicorn.conf.py +++ b/src/ui/gunicorn.conf.py @@ -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 = {} diff --git a/src/ui/main.py b/src/ui/main.py index 41e94f4d6..abe7fe3de 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -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