This commit is contained in:
concordia
2024-06-15 20:20:54 -05:00
parent 9dc2951e07
commit 720c9ccbc8
2 changed files with 73 additions and 97 deletions

View File

@@ -52,6 +52,10 @@ def frogpilot_boot_functions(frogpilot_functions):
print(f"An unexpected error occurred: {e}")
def manager_init(frogpilot_functions) -> None:
timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
log_dir = f"/data/log2/{timestamp}"
os.makedirs(log_dir, exist_ok=True)
frogpilot_boot = threading.Thread(target=frogpilot_boot_functions, args=(frogpilot_functions,))
frogpilot_boot.start()
@@ -354,6 +358,8 @@ def manager_init(frogpilot_functions) -> None:
for p in managed_processes.values():
p.prepare()
return log_dir
def manager_cleanup() -> None:
# send signals to kill all procs
@@ -368,7 +374,7 @@ def manager_cleanup() -> None:
last_running = ""
def manager_thread(frogpilot_functions) -> None:
def manager_thread(frogpilot_functions, log_dir) -> None:
global last_running
cloudlog.bind(daemon="manager")
@@ -389,7 +395,7 @@ def manager_thread(frogpilot_functions) -> None:
pm = messaging.PubMaster(['managerState'])
write_onroad_params(False, params)
ensure_running(managed_processes.values(), False, params=params, CP=sm['carParams'], not_run=ignore)
ensure_running(managed_processes.values(), False, params=params, CP=sm['carParams'], not_run=ignore, log_dir=log_dir)
started_prev = False
@@ -418,7 +424,7 @@ def manager_thread(frogpilot_functions) -> None:
started_prev = started
ensure_running(managed_processes.values(), started, params=params, CP=sm['carParams'], not_run=ignore)
ensure_running(managed_processes.values(), started, params=params, CP=sm['carParams'], not_run=ignore, log_dir=log_dir)
running = ' '.join("{}{}\u001b[0m".format("\u001b[32m" if p.proc.is_alive() else "\u001b[31m", p.name)
for p in managed_processes.values() if p.proc)