wip
This commit is contained in:
@@ -20,6 +20,8 @@ from openpilot.common.swaglog import cloudlog
|
||||
WATCHDOG_FN = "/dev/shm/wd_"
|
||||
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None
|
||||
|
||||
_log_dir = ""
|
||||
|
||||
def nativelauncher(pargs: list[str], cwd: str, name: str, log_path: str) -> None:
|
||||
os.environ['MANAGER_DAEMON'] = name
|
||||
with open(log_path, 'a') as log_file:
|
||||
@@ -71,7 +73,6 @@ class ManagerProcess(ABC):
|
||||
def start(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def restart(self) -> None:
|
||||
if self.proc is not None and self.proc.exitcode is not None:
|
||||
self.stop(sig=signal.SIGKILL, block=False)
|
||||
@@ -150,7 +151,9 @@ class NativeProcess(ManagerProcess):
|
||||
def prepare(self) -> None:
|
||||
pass
|
||||
|
||||
def start(self, log_path: str) -> None:
|
||||
def start(self) -> None:
|
||||
global _log_dir
|
||||
log_path = _log_dir+"/"+self.name+".log"
|
||||
if self.shutting_down or self.proc is not None:
|
||||
return
|
||||
self.proc = Process(target=nativelauncher, args=(self.cmdline, os.path.join(BASEDIR, self.cwd), self.name, log_path))
|
||||
@@ -171,7 +174,9 @@ class PythonProcess(ManagerProcess):
|
||||
cloudlog.info(f"preimporting {self.module}")
|
||||
importlib.import_module(self.module)
|
||||
|
||||
def start(self, log_path: str) -> None:
|
||||
def start(self) -> None:
|
||||
global _log_dir
|
||||
log_path = _log_dir+"/"+self.name+".log"
|
||||
if self.shutting_down or self.proc is not None:
|
||||
return
|
||||
self.proc = Process(name=self.name, target=launcher, args=(self.module, self.name, log_path))
|
||||
@@ -196,7 +201,9 @@ class DaemonProcess(ManagerProcess):
|
||||
def prepare(self) -> None:
|
||||
pass
|
||||
|
||||
def start(self, log_path: str) -> None:
|
||||
def start(self) -> None:
|
||||
global _log_dir
|
||||
log_path = _log_dir+"/"+self.name+".log"
|
||||
if self.params is None:
|
||||
self.params = Params()
|
||||
|
||||
@@ -222,15 +229,16 @@ class DaemonProcess(ManagerProcess):
|
||||
|
||||
|
||||
def ensure_running(procs: ValuesView[ManagerProcess], started: bool, params=None, CP: car.CarParams=None, not_run: list[str] | None=None, log_dir: str = None) -> list[ManagerProcess]:
|
||||
global _log_dir
|
||||
_log_dir = log_dir
|
||||
if not_run is None:
|
||||
not_run = []
|
||||
|
||||
running = []
|
||||
for p in procs:
|
||||
log_path = log_dir+"/"+p.name+".log"
|
||||
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:
|
||||
p.start(log_path)
|
||||
p.start()
|
||||
running.append(p)
|
||||
else:
|
||||
p.stop(block=False)
|
||||
|
||||
Reference in New Issue
Block a user