This commit is contained in:
Comma Device
2024-06-17 16:57:23 +00:00
parent 0c36ffdfde
commit 7f182b7fae
9 changed files with 34 additions and 19 deletions

0
selfdrive/clearpilot/resource/debug_ui_scene.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

View File

View File

View File

View File

View File

@@ -27,26 +27,42 @@ def nativelauncher(pargs: list[str], cwd: str, name: str, log_path: str) -> None
with open(log_path, 'a') as log_file:
os.chdir(cwd)
proc = subprocess.Popen(pargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True)
log_file.write("Started "+name)
for line in proc.stdout:
print(line, end='')
log_file.write(line)
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(proc)
setproctitle(name)
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:
for line in proc.stdout:
# 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)
proc.wait()
except Exception:
# 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()
raise
def join_process(process: Process, timeout: float) -> None:
t = time.monotonic()
@@ -215,14 +231,13 @@ class DaemonProcess(ManagerProcess):
except OSError:
pass # Process not running, continue to start it
log_file_path = os.path.join(log_path, f"{self.name}.log")
self.params.put(self.param_name, str(self.proc.pid))
cloudlog.info(f"starting daemon {self.name}")
self.proc = subprocess.Popen(['python', '-m', self.module],
stdin=open('/dev/null'),
stdout=open(log_file_path, 'a'),
stdout=open(log_path, 'a'),
stderr=subprocess.STDOUT,
preexec_fn=os.setpgrp)
self.params.put(self.param_name, str(self.proc.pid))
def stop(self, retry=True, block=True, sig=None) -> None:
pass
@@ -237,7 +252,7 @@ def ensure_running(procs: ValuesView[ManagerProcess], started: bool, params=None
running = []
for p in procs:
if p.enabled and p.name not in not_run and p.should_run(started, params, CP):
if p.proc is None or p.proc.exitcode is not None:
if p.proc is None or (hasattr(p.proc, 'exitcode') and p.proc.exitcode is not None):
p.start()
running.append(p)
else:

0
system/clearpilot/dev/on_start_brian.sh.cpt Normal file → Executable file
View File