def main() -> int: """Start Home Assistant.""" validate_python() if os.environ.get('HASS_NO_MONKEY') != '1': if sys.version_info[:2] >= (3, 6): monkey_patch.disable_c_asyncio() monkey_patch.patch_weakref_tasks() attempt_use_uvloop() args = get_arguments() if args.script is not None: from homeassistant import scripts return scripts.run(args.script) config_dir = os.path.join(os.getcwd(), args.config) ensure_config_path(config_dir) # Daemon functions if args.pid_file: check_pid(args.pid_file) if args.daemon: daemonize() if args.pid_file: write_pid(args.pid_file) exit_code = setup_and_run_hass(config_dir, args) if exit_code == RESTART_EXIT_CODE and not args.runner: try_to_restart() return exit_code
def main() -> int: """Start Home Assistant.""" validate_python() if os.environ.get('HASS_NO_MONKEY') != '1': if sys.version_info[:2] >= (3, 6): monkey_patch.disable_c_asyncio() monkey_patch.patch_weakref_tasks() attempt_use_uvloop() args = get_arguments() if args.script is not None: from homeassistant import scripts return scripts.run(args.script) config_dir = os.path.join(os.getcwd(), args.config) ensure_config_path(config_dir) # Daemon functions if args.pid_file: check_pid(args.pid_file) if args.daemon: daemonize() if args.pid_file: write_pid(args.pid_file) exit_code = setup_and_run_hass(config_dir, args) if exit_code == RESTART_EXIT_CODE and not args.runner: try_to_restart() return exit_code
def main() -> int: """Start Home Assistant.""" validate_python() monkey_patch_needed = sys.version_info[:3] < (3, 6, 3) if monkey_patch_needed and os.environ.get("HASS_NO_MONKEY") != "1": monkey_patch.disable_c_asyncio() monkey_patch.patch_weakref_tasks() 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: from homeassistant import scripts return scripts.run(args.script) config_dir = os.path.join(os.getcwd(), args.config) ensure_config_path(config_dir) # Daemon functions if args.pid_file: check_pid(args.pid_file) if args.daemon: daemonize() if args.pid_file: write_pid(args.pid_file) from homeassistant.util.async_ import asyncio_run exit_code = asyncio_run(setup_and_run_hass(config_dir, args)) if exit_code == RESTART_EXIT_CODE and not args.runner: try_to_restart() return exit_code # type: ignore
def main() -> int: """Start Home Assistant.""" validate_python() monkey_patch_needed = sys.version_info[:3] < (3, 6, 3) if monkey_patch_needed and os.environ.get('HASS_NO_MONKEY') != '1': if sys.version_info[:2] >= (3, 6): monkey_patch.disable_c_asyncio() monkey_patch.patch_weakref_tasks() 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: from homeassistant import scripts return scripts.run(args.script) config_dir = os.path.join(os.getcwd(), args.config) ensure_config_path(config_dir) # Daemon functions if args.pid_file: check_pid(args.pid_file) if args.daemon: daemonize() if args.pid_file: write_pid(args.pid_file) from homeassistant.util.async_ import asyncio_run exit_code = asyncio_run(setup_and_run_hass(config_dir, args)) if exit_code == RESTART_EXIT_CODE and not args.runner: try_to_restart() return exit_code # type: ignore # mypy cannot yet infer it