diff --git a/fixcore/fixcore/__main__.py b/fixcore/fixcore/__main__.py index 14a583ede9..d74ad71b00 100644 --- a/fixcore/fixcore/__main__.py +++ b/fixcore/fixcore/__main__.py @@ -67,6 +67,7 @@ from fixcore.web.certificate_handler import CertificateHandlerWithCA, CertificateHandlerNoCA from fixcore.worker_task_queue import WorkerTaskQueue from fixlib.asynchronous.web import runner +from fixlib.utils import ensure_bw_compat log = logging.getLogger("fixcore") @@ -75,6 +76,7 @@ def main() -> None: """ Application entrypoint - no arguments are allowed. """ + ensure_bw_compat() try: run(sys.argv[1:]) log.info("Process finished.") diff --git a/fixlib/fixlib/utils.py b/fixlib/fixlib/utils.py index cff6161724..466dba7388 100644 --- a/fixlib/fixlib/utils.py +++ b/fixlib/fixlib/utils.py @@ -573,3 +573,14 @@ def freeze(elem: JsonElement) -> Any: return frozendict({k: freeze(v) for k, v in elem.items()}) else: return elem + + +def ensure_bw_compat() -> None: + for i, arg in enumerate(sys.argv): + if arg.startswith("--resoto"): + sys.argv[i] = "--fix" + arg[len("--resoto") :] + + old_env_vars = [key for key in os.environ if key.startswith("RESOTO")] + for old_env_var in old_env_vars: + new_env_var = "FIX" + old_env_var[len("RESOTO") :] + os.environ[new_env_var] = os.environ.pop(old_env_var) diff --git a/fixmetrics/fixmetrics/__main__.py b/fixmetrics/fixmetrics/__main__.py index 97c1866684..ac3eeddde2 100644 --- a/fixmetrics/fixmetrics/__main__.py +++ b/fixmetrics/fixmetrics/__main__.py @@ -29,6 +29,7 @@ from threading import Event from typing import Optional from fixlib.args import ArgumentParser +from fixlib.utils import ensure_bw_compat shutdown_event = Event() @@ -45,6 +46,7 @@ def shutdown(event: FixEvent) -> None: def main() -> None: + ensure_bw_compat() setup_logger("fixmetrics") fixlib.proc.parent_pid = os.getpid() diff --git a/fixshell/fixshell/__main__.py b/fixshell/fixshell/__main__.py index ca517507ac..6b48558c7e 100644 --- a/fixshell/fixshell/__main__.py +++ b/fixshell/fixshell/__main__.py @@ -20,6 +20,7 @@ from fixshell import authorized_client from fixshell.promptsession import PromptSession, core_metadata, FixHistory from fixshell.shell import Shell, ShutdownShellError +from fixlib.utils import ensure_bw_compat async def main_async() -> None: @@ -218,6 +219,7 @@ def header_value(s: str) -> Tuple[str, str]: def main() -> None: + ensure_bw_compat() asyncio.run(main_async()) fixlib.proc.kill_children(SIGTERM, ensure_death=True) log.debug("Shutdown complete") diff --git a/fixworker/fixworker/__main__.py b/fixworker/fixworker/__main__.py index ea1b9d1b79..b6e2320ef7 100644 --- a/fixworker/fixworker/__main__.py +++ b/fixworker/fixworker/__main__.py @@ -34,6 +34,7 @@ from fixworker.fixcore import FixCore from fixworker.tag import core_tag_tasks_processor from fixworker.exceptions import DuplicateMessageError +from fixlib.utils import ensure_bw_compat # This will be used in main() and shutdown() shutdown_event = threading.Event() @@ -42,6 +43,7 @@ def main() -> None: + ensure_bw_compat() setup_logger("fixworker") # Try to run in a new process group and # ignore if not possible for whatever reason