From 02d66a346d38b9d13676ed719851ab0e3a646ed7 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 21 Jun 2023 11:03:07 -0400 Subject: [PATCH] server: add support for instance uuids Signed-off-by: Eric Callahan --- moonraker/server.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/moonraker/server.py b/moonraker/server.py index 4a0e6b0..658b24d 100755 --- a/moonraker/server.py +++ b/moonraker/server.py @@ -17,6 +17,7 @@ import socket import logging import signal import asyncio +import uuid from . import confighelper from .eventloop import EventLoop from .app import MoonrakerApp @@ -509,6 +510,12 @@ def main(from_package: bool = True) -> None: startup_warnings.append( f"Unable to create data path folder at {data_path}" ) + uuid_path = data_path.joinpath(".moonraker.uuid") + if not uuid_path.is_file(): + instance_uuid = uuid.uuid4().hex + uuid_path.write_text(instance_uuid) + else: + instance_uuid = uuid_path.read_text().strip() if cmd_line_args.configfile is not None: cfg_file: str = cmd_line_args.configfile else: @@ -522,7 +529,8 @@ def main(from_package: bool = True) -> None: "debug": cmd_line_args.debug, "asyncio_debug": cmd_line_args.asyncio_debug, "is_backup_config": False, - "is_python_package": from_package + "is_python_package": from_package, + "instance_uuid": instance_uuid } # Setup Logging