cloudlog: add daemon name to context for python daemons (#23225)

* python

* manager is a daemon too

* Update selfdrive/manager/process.py

Co-authored-by: Comma Device <device@comma.ai>
pull/23024/head
Adeeb Shihadeh 2021-12-14 20:43:26 -08:00 committed by GitHub
parent fa62b9d3f9
commit b27a19e9d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -117,6 +117,7 @@ def manager_cleanup():
def manager_thread():
cloudlog.bind(daemon="manager")
cloudlog.info("manager start")
cloudlog.info({"environ": os.environ})

View File

@ -22,7 +22,7 @@ WATCHDOG_FN = "/dev/shm/wd_"
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None
def launcher(proc):
def launcher(proc, name):
try:
# import the process
mod = importlib.import_module(proc)
@ -33,6 +33,9 @@ def launcher(proc):
# create new context since we forked
messaging.context = messaging.Context()
# add daemon name to cloudlog ctx
cloudlog.bind(daemon=name)
# exec the process
mod.main()
except KeyboardInterrupt:
@ -223,7 +226,7 @@ class PythonProcess(ManagerProcess):
return
cloudlog.info("starting python %s" % self.module)
self.proc = Process(name=self.name, target=launcher, args=(self.module,))
self.proc = Process(name=self.name, target=launcher, args=(self.module, self.name))
self.proc.start()
self.watchdog_seen = False
self.shutting_down = False