This commit is contained in:
Comma Device
2024-06-17 17:10:43 +00:00
parent 7f182b7fae
commit 75c91213a2

View File

@@ -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,34 +34,22 @@ 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:
for _ in iter(int, 1):
try:
# Initialize the module and setup the process title and logging
mod = importlib.import_module(proc)
setproctitle(name)
setproctitle(proc)
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, ''):
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)
# Wait for the subprocess to terminate
proc_instance.wait()
proc.wait()
except Exception as e:
# Log the error and restart the process after logging the exception
print(f"Fatal: {name}")
print(e)
print ("Fatal: "+name)
print (e)
sentry.capture_exception()
def join_process(process: Process, timeout: float) -> None: