From 6ecd00ceecddab85cad2991624edf1763f86d919 Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Fri, 21 Sep 2018 11:51:32 -0700 Subject: [PATCH] Move windows restart handler out of setup_and_run_hass --- homeassistant/__main__.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 25aa765ac..91b7a7f84 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -248,19 +248,6 @@ async def setup_and_run_hass(config_dir: str, """Set up HASS and run.""" from homeassistant import bootstrap, core - # Run a simple daemon runner process on Windows to handle restarts - if os.name == 'nt' and '--runner' not in sys.argv: - nt_args = cmdline() + ['--runner'] - while True: - try: - subprocess.check_call(nt_args) - sys.exit(0) - except KeyboardInterrupt: - sys.exit(0) - except subprocess.CalledProcessError as exc: - if exc.returncode != RESTART_EXIT_CODE: - sys.exit(exc.returncode) - hass = core.HomeAssistant() if args.demo_mode: @@ -353,6 +340,19 @@ def main() -> int: set_loop() + # Run a simple daemon runner process on Windows to handle restarts + if os.name == 'nt' and '--runner' not in sys.argv: + nt_args = cmdline() + ['--runner'] + while True: + try: + subprocess.check_call(nt_args) + sys.exit(0) + except KeyboardInterrupt: + sys.exit(0) + except subprocess.CalledProcessError as exc: + if exc.returncode != RESTART_EXIT_CODE: + sys.exit(exc.returncode) + args = get_arguments() if args.script is not None: