diff --git a/core/admin/start.py b/core/admin/start.py index d8165ff3..2c925e01 100755 --- a/core/admin/start.py +++ b/core/admin/start.py @@ -1,6 +1,10 @@ #!/usr/bin/python3 import os +import logging as log +import sys + +log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "INFO")) os.system("flask mailu advertise") os.system("flask db upgrade") @@ -11,6 +15,14 @@ password = os.environ.get("INITIAL_ADMIN_PW") if account is not None and domain is not None and password is not None: mode = os.environ.get("INITIAL_ADMIN_MODE", default="ifmissing") + log.info("Creating initial admin accout %s@%s with mode %s",account,domain,mode) os.system("flask mailu admin %s %s '%s' --mode %s" % (account, domain, password, mode)) -os.system("gunicorn -w 4 -b :80 --access-logfile - --error-logfile - --preload 'mailu:create_app()'") +start_command="".join([ + "gunicorn -w 4 -b :80 ", + "--access-logfile - " if (log.root.level<=log.INFO) else "", + "--error-logfile - ", + "--preload ", + "'mailu:create_app()'"]) + +os.system(start_command) diff --git a/towncrier/newsfragments/1197.feature b/towncrier/newsfragments/1197.feature new file mode 100644 index 00000000..0aae8a08 --- /dev/null +++ b/towncrier/newsfragments/1197.feature @@ -0,0 +1 @@ +Enable access log of admin service only for log levels of INFO and finer \ No newline at end of file