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