From 1ad1d8d95d7dc77b729dc9a1e329d3b1cd6fb7c1 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 25 Jan 2023 15:15:24 +0100 Subject: [PATCH] Rewrite generation of gunicorn cmdline --- core/admin/start.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/core/admin/start.py b/core/admin/start.py index debb4ec7..f92d845e 100755 --- a/core/admin/start.py +++ b/core/admin/start.py @@ -52,20 +52,21 @@ def test_DNS(): test_DNS() -bind_addr = ":80" -if os.environ.get("SUBNET6") is not None: - # If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4 - bind_addr = "[::]:80" - -start_command=" ".join([ - "gunicorn", - f"--threads {str(os.cpu_count())}", - "-b", bind_addr, +cmdline = [ + "gunicorn", + "--threads", f"{os.cpu_count()}", + # If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4 + "-b", f"{'[::]' if os.environ.get('SUBNET6') else ''}:80", "--logger-class mailu.Logger", "--worker-tmp-dir /dev/shm", - "--access-logfile -" if (log.root.level<=log.INFO) else "", - "--error-logfile -", - "--preload", - "'mailu:create_app()'"]) + "--error-logfile", "-", + "--preload" +] -os.system(start_command) +# logging +if log.root.level <= log.INFO: + cmdline.extend(["--access-logfile", "-"]) + +cmdline.append("'mailu:create_app()'") + +os.system(" ".join(cmdline))