Process config cleanup (#20276)

* add enabled flag

* remove hack

* only prepare when enabled
albatross
Willem Melching 2021-03-08 12:18:58 +01:00 committed by GitHub
parent 12928cdae2
commit 476558b547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 32 deletions

View File

@ -58,6 +58,7 @@ class ManagerProcess(ABC):
daemon = False
sigkill = False
proc = None
enabled = True
name = ""
@abstractmethod
@ -123,10 +124,11 @@ class ManagerProcess(ABC):
class NativeProcess(ManagerProcess):
def __init__(self, name, cwd, cmdline, persistent=False, driverview=False, unkillable=False, sigkill=False):
def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False):
self.name = name
self.cwd = cwd
self.cmdline = cmdline
self.enabled = enabled
self.persistent = persistent
self.driverview = driverview
self.unkillable = unkillable
@ -146,17 +148,19 @@ class NativeProcess(ManagerProcess):
class PythonProcess(ManagerProcess):
def __init__(self, name, module, persistent=False, driverview=False, unkillable=False, sigkill=False):
def __init__(self, name, module, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False):
self.name = name
self.module = module
self.enabled = enabled
self.persistent = persistent
self.driverview = driverview
self.unkillable = unkillable
self.sigkill = sigkill
def prepare(self):
cloudlog.info("preimporting %s" % self.module)
importlib.import_module(self.module)
if self.enabled:
cloudlog.info("preimporting %s" % self.module)
importlib.import_module(self.module)
def start(self):
if self.proc is not None:
@ -170,10 +174,11 @@ class PythonProcess(ManagerProcess):
class DaemonProcess(ManagerProcess):
"""Python process that has to stay running accross manager restart.
This is used for athena so you don't lose SSH access when restarting manager."""
def __init__(self, name, module, param_name):
def __init__(self, name, module, param_name, enabled=True):
self.name = name
self.module = module
self.param_name = param_name
self.enabled = enabled
self.persistent = True
def prepare(self):
@ -215,6 +220,8 @@ def ensure_running(procs, started, driverview=False, not_run=None):
for p in procs:
if p.name in not_run:
p.stop()
elif not p.enabled:
p.stop()
elif p.persistent:
p.start()
elif p.driverview and driverview:

View File

@ -10,47 +10,30 @@ procs = [
# due to qualcomm kernel bugs SIGKILLing camerad sometimes causes page table corruption
NativeProcess("camerad", "selfdrive/camerad", ["./camerad"], unkillable=True, driverview=True),
NativeProcess("clocksd", "selfdrive/clocksd", ["./clocksd"]),
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], enabled=(not PC or WEBCAM), driverview=True),
NativeProcess("logcatd", "selfdrive/logcatd", ["./logcatd"]),
NativeProcess("loggerd", "selfdrive/loggerd", ["./loggerd"]),
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]),
NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]),
NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC, persistent=EON, sigkill=EON),
NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)),
NativeProcess("ui", "selfdrive/ui", ["./ui"], persistent=True),
PythonProcess("calibrationd", "selfdrive.locationd.calibrationd"),
PythonProcess("controlsd", "selfdrive.controls.controlsd"),
PythonProcess("deleter", "selfdrive.loggerd.deleter", persistent=True),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", enabled=(not PC or WEBCAM), driverview=True),
PythonProcess("locationd", "selfdrive.locationd.locationd"),
PythonProcess("logmessaged", "selfdrive.logmessaged", persistent=True),
PythonProcess("pandad", "selfdrive.pandad", persistent=True),
PythonProcess("paramsd", "selfdrive.locationd.paramsd"),
PythonProcess("plannerd", "selfdrive.controls.plannerd"),
PythonProcess("radard", "selfdrive.controls.radard"),
PythonProcess("rtshield", "selfdrive.rtshield", enabled=EON),
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),
]
if not PC:
procs += [
NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], persistent=EON, sigkill=EON),
PythonProcess("tombstoned", "selfdrive.tombstoned", persistent=True),
PythonProcess("updated", "selfdrive.updated", persistent=True),
]
if not PC or WEBCAM:
procs += [
NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"]),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview=True),
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview=True),
]
if TICI:
procs += [
PythonProcess("timezoned", "selfdrive.timezoned", persistent=True),
]
if EON:
procs += [
PythonProcess("rtshield", "selfdrive.rtshield"),
]
managed_processes = {p.name: p for p in procs}

View File

@ -14,8 +14,6 @@ from cereal import car, log
from cereal.services import service_list
from common.params import Params
from selfdrive.car.car_helpers import get_car
os.environ['WEBCAM'] = '1' # hack to get dmonitoringd in managed_processes
from selfdrive.manager.process import PythonProcess
from selfdrive.manager.process_config import managed_processes