manager: cleanup ensure_running (#24270)

* manager: cleanup ensure_running

* make notcar a blocking condition

* invert last conditions

* duplicate

* always run daemon process

* comment

* typo

* make notcar like driverview
old-commit-hash: 207df4742f
taco
Willem Melching 3 years ago committed by GitHub
parent f1dce8540a
commit 373ac5ce3d
  1. 46
      selfdrive/manager/process.py
  2. 28
      selfdrive/manager/process_config.py

@ -69,7 +69,8 @@ class ManagerProcess(ABC):
unkillable = False
daemon = False
sigkill = False
persistent = False
onroad = True
offroad = False
driverview = False
notcar = False
proc: Optional[Process] = None
@ -183,12 +184,13 @@ class ManagerProcess(ABC):
class NativeProcess(ManagerProcess):
def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
def __init__(self, name, cwd, cmdline, enabled=True, onroad=True, offroad=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
self.name = name
self.cwd = cwd
self.cmdline = cmdline
self.enabled = enabled
self.persistent = persistent
self.onroad = onroad
self.offroad = offroad
self.driverview = driverview
self.notcar = notcar
self.unkillable = unkillable
@ -215,11 +217,12 @@ class NativeProcess(ManagerProcess):
class PythonProcess(ManagerProcess):
def __init__(self, name, module, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
def __init__(self, name, module, enabled=True, onroad=True, offroad=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
self.name = name
self.module = module
self.enabled = enabled
self.persistent = persistent
self.onroad = onroad
self.offroad = offroad
self.driverview = driverview
self.notcar = notcar
self.unkillable = unkillable
@ -254,7 +257,8 @@ class DaemonProcess(ManagerProcess):
self.module = module
self.param_name = param_name
self.enabled = enabled
self.persistent = True
self.onroad = True
self.offroad = True
def prepare(self) -> None:
pass
@ -293,23 +297,23 @@ def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview:
not_run = []
for p in procs:
if p.name in not_run:
p.stop(block=False)
elif not p.enabled:
p.stop(block=False)
elif p.persistent:
p.start()
elif p.driverview and driverview:
p.start()
elif p.notcar:
if notcar:
p.start()
else:
p.stop(block=False)
elif started:
# Conditions that make a process run
run = any((
p.offroad and not started,
p.onroad and started,
p.driverview and driverview,
p.notcar and notcar,
))
# Conditions that block a process from starting
run = run and not any((
not p.enabled,
p.name in not_run,
))
if run:
p.start()
else:
p.stop(block=False)
p.check_watchdog(started)

@ -14,32 +14,32 @@ procs = [
NativeProcess("logcatd", "selfdrive/logcatd", ["./logcatd"]),
NativeProcess("loggerd", "selfdrive/loggerd", ["./loggerd"]),
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]),
NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], persistent=True),
NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], offroad=True),
NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]),
NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC),
NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)),
NativeProcess("ui", "selfdrive/ui", ["./ui"], persistent=True, watchdog_max_dt=(5 if TICI else None)),
NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"], persistent=True),
NativeProcess("ui", "selfdrive/ui", ["./ui"], offroad=True, watchdog_max_dt=(5 if TICI else None)),
NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"], offroad=True),
NativeProcess("locationd", "selfdrive/locationd", ["./locationd"]),
NativeProcess("boardd", "selfdrive/boardd", ["./boardd"], enabled=False),
PythonProcess("calibrationd", "selfdrive.locationd.calibrationd"),
PythonProcess("controlsd", "selfdrive.controls.controlsd"),
PythonProcess("deleter", "selfdrive.loggerd.deleter", persistent=True),
PythonProcess("deleter", "selfdrive.loggerd.deleter", offroad=True),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", enabled=(not PC or WEBCAM), driverview=True),
PythonProcess("logmessaged", "selfdrive.logmessaged", persistent=True),
PythonProcess("pandad", "selfdrive.boardd.pandad", persistent=True),
PythonProcess("logmessaged", "selfdrive.logmessaged", offroad=True),
PythonProcess("pandad", "selfdrive.boardd.pandad", offroad=True),
PythonProcess("paramsd", "selfdrive.locationd.paramsd"),
PythonProcess("plannerd", "selfdrive.controls.plannerd"),
PythonProcess("radard", "selfdrive.controls.radard"),
PythonProcess("thermald", "selfdrive.thermald.thermald", persistent=True),
PythonProcess("timezoned", "selfdrive.timezoned", enabled=TICI, persistent=True),
PythonProcess("tombstoned", "selfdrive.tombstoned", enabled=not PC, persistent=True),
PythonProcess("updated", "selfdrive.updated", enabled=not PC, persistent=True),
PythonProcess("uploader", "selfdrive.loggerd.uploader", persistent=True),
PythonProcess("statsd", "selfdrive.statsd", persistent=True),
PythonProcess("thermald", "selfdrive.thermald.thermald", offroad=True),
PythonProcess("timezoned", "selfdrive.timezoned", enabled=TICI, offroad=True),
PythonProcess("tombstoned", "selfdrive.tombstoned", enabled=not PC, offroad=True),
PythonProcess("updated", "selfdrive.updated", enabled=not PC, offroad=True),
PythonProcess("uploader", "selfdrive.loggerd.uploader", offroad=True),
PythonProcess("statsd", "selfdrive.statsd", offroad=True),
NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar=True),
PythonProcess("webjoystick", "tools.joystick.web", notcar=True),
NativeProcess("bridge", "cereal/messaging", ["./bridge"], onroad=False, notcar=True),
PythonProcess("webjoystick", "tools.joystick.web", onroad=False, notcar=True),
# Experimental
PythonProcess("rawgpsd", "selfdrive.sensord.rawgps.rawgpsd", enabled=os.path.isfile("/persist/comma/use-quectel-rawgps")),

Loading…
Cancel
Save