Skip to content

Commit

Permalink
WebHost: config override (#3701)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored Sep 2, 2024
1 parent 7370129 commit 7657218
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions WebHost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import os
import multiprocessing
import logging
Expand Down Expand Up @@ -31,6 +32,15 @@ def get_app() -> "Flask":
import yaml
app.config.from_file(configpath, yaml.safe_load)
logging.info(f"Updated config from {configpath}")
# inside get_app() so it's usable in systems like gunicorn, which do not run WebHost.py, but import it.
parser = argparse.ArgumentParser()
parser.add_argument('--config_override', default=None,
help="Path to yaml config file that overrules config.yaml.")
args = parser.parse_known_args()[0]
if args.config_override:
import yaml
app.config.from_file(os.path.abspath(args.config_override), yaml.safe_load)
logging.info(f"Updated config from {args.config_override}")
if not app.config["HOST_ADDRESS"]:
logging.info("Getting public IP, as HOST_ADDRESS is empty.")
app.config["HOST_ADDRESS"] = Utils.get_public_ipv4()
Expand Down

0 comments on commit 7657218

Please sign in to comment.