Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api/utils/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from biscuit_auth import KeyPair, PublicKey, PrivateKey

from common_utils import effective_cpu_count, handle_docker_secrets # type: ignore
from common_utils import effective_cpu_count, getenv_bool, handle_docker_secrets # type: ignore
from logger import getLogger, log_types # type: ignore

from app.models.api_database import APIDatabase
Expand Down Expand Up @@ -120,7 +120,7 @@
graceful_timeout = 30
http_protocols = "h3,h2,h1"

DEBUG = getenv("DEBUG", False)
DEBUG = getenv_bool("DEBUG")

loglevel = "debug" if DEBUG else LOG_LEVEL.lower()

Expand Down
4 changes: 4 additions & 0 deletions src/common/utils/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
PLUGIN_TAR_COMPRESS_LEVEL: int = 3


def getenv_bool(name: str, default: str = "no") -> bool:
return getenv(name, default).strip().lower() in ("1", "true", "yes", "on")


def handle_docker_secrets() -> Dict[str, str]:
"""Handle Docker secrets by reading from /run/secrets directory (Alpine only)"""
secrets = {}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/utils/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from biscuit_auth import KeyPair, PublicKey, PrivateKey
from passlib.totp import generate_secret

from common_utils import effective_cpu_count, handle_docker_secrets # type: ignore
from common_utils import effective_cpu_count, getenv_bool, handle_docker_secrets # type: ignore
from logger import getLogger, log_types # type: ignore

from app.models.ui_database import UIDatabase
Expand Down Expand Up @@ -120,7 +120,7 @@
graceful_timeout = 30
http_protocols = "h1" # TODO: add h2 when fixed and h3 when supported

DEBUG = getenv("DEBUG", False)
DEBUG = getenv_bool("DEBUG")

loglevel = "debug" if DEBUG else LOG_LEVEL.lower()

Expand Down
4 changes: 2 additions & 2 deletions src/ui/utils/tmp-gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if deps_path not in sys_path:
sys_path.append(deps_path)

from common_utils import handle_docker_secrets # type: ignore
from common_utils import getenv_bool, handle_docker_secrets # type: ignore
from logger import getLogger, log_types # type: ignore

TMP_DIR = Path(sep, "var", "tmp", "bunkerweb")
Expand All @@ -29,7 +29,7 @@
)
PROXY_ALLOW_IPS = getenv("UI_PROXY_ALLOW_IPS", getenv("PROXY_ALLOW_IPS", FORWARDED_ALLOW_IPS))
CAPTURE_OUTPUT = getenv("CAPTURE_OUTPUT", "no").lower() == "yes"
DEBUG = getenv("DEBUG", False)
DEBUG = getenv_bool("DEBUG")

if CAPTURE_OUTPUT or "file" in log_types:
errorlog = getenv("LOG_FILE_PATH", join(sep, "var", "log", "bunkerweb", "tmp-ui.log"))
Expand Down