From 75c91213a2edf4d2d0e303a232a4153404b1ed8a Mon Sep 17 00:00:00 2001 From: Comma Device Date: Mon, 17 Jun 2024 17:10:43 +0000 Subject: [PATCH] wip --- selfdrive/manager/process.py | 48 ++++++++++++++---------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index b72772a..d17eaad 100755 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -19,7 +19,7 @@ from openpilot.common.swaglog import cloudlog WATCHDOG_FN = "/dev/shm/wd_" ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None - +ENABLE_WATCHDOG = False # Fixme _log_dir = "" def nativelauncher(pargs: list[str], cwd: str, name: str, log_path: str) -> None: @@ -34,35 +34,23 @@ def nativelauncher(pargs: list[str], cwd: str, name: str, log_path: str) -> None proc.wait() def launcher(proc: str, name: str, log_path: str) -> None: - while True: - try: - # Initialize the module and setup the process title and logging - mod = importlib.import_module(proc) - setproctitle(name) - messaging.context = messaging.Context() - cloudlog.bind(daemon=name) - sentry.set_tag("daemon", name) - - # Command to run the process - command = ['python', '-m', proc] - - # Open the log file and start the subprocess - with open(log_path, 'a') as log_file, subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as proc_instance: - log_file.write(f"Started {name}\n") - - # Process the output from the subprocess - for line in iter(proc_instance.stdout.readline, ''): - print(line, end='') - log_file.write(line) - - # Wait for the subprocess to terminate - proc_instance.wait() - - except Exception as e: - # Log the error and restart the process after logging the exception - print(f"Fatal: {name}") - print(e) - sentry.capture_exception() + for _ in iter(int, 1): + try: + mod = importlib.import_module(proc) + setproctitle(proc) + messaging.context = messaging.Context() + cloudlog.bind(daemon=name) + sentry.set_tag("daemon", name) + with open(log_path, 'a') as log_file, subprocess.Popen(['python', '-m', proc], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as proc: + log_file.write("Started "+name) + for line in proc.stdout: + print(line, end='') + log_file.write(line) + proc.wait() + except Exception as e: + print ("Fatal: "+name) + print (e) + sentry.capture_exception() def join_process(process: Process, timeout: float) -> None: t = time.monotonic()