Skip to content

Commit

Permalink
cloudlog: add daemon name to context for python daemons (#23225)
Browse files Browse the repository at this point in the history
* python

* manager is a daemon too

* Update selfdrive/manager/process.py

Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
adeebshihadeh and Comma Device authored Dec 15, 2021
1 parent fa62b9d commit b27a19e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions selfdrive/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def manager_cleanup():


def manager_thread():
cloudlog.bind(daemon="manager")
cloudlog.info("manager start")
cloudlog.info({"environ": os.environ})

Expand Down
7 changes: 5 additions & 2 deletions selfdrive/manager/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None


def launcher(proc):
def launcher(proc, name):
try:
# import the process
mod = importlib.import_module(proc)
Expand All @@ -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:
Expand Down Expand Up @@ -223,7 +226,7 @@ def start(self):
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
Expand Down

0 comments on commit b27a19e

Please sign in to comment.