Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions daemons/generic/pdu
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ class Pdu(HispecDaemon): #pylint: disable = W0223
self.keyword_registry.string("status",
getter=self.keyword_wrapper(self.status, key="status"),
description="JSON status summary of the PDU and all outlets.")
self.keyword_registry.trigger("shutdown",
action=self._shutdown,
description="Shutdown the daemon now.")

for outlet in self.outlets:
outlet.register_keywords(self.keyword_registry)
Expand Down Expand Up @@ -349,6 +352,13 @@ class Pdu(HispecDaemon): #pylint: disable = W0223
return self._fail(str(e))
return {"ok": True, "status": json.dumps(status)}

def _shutdown(self):
"""Shutdown the daemon"""
self.logger.info("Shutting down")
if self.dev is not None:
self.dev.disconnect()
self.request_stop()

def _get_device_str(self, item: str) -> str:
"""Read a device-level (no outlet number) string item from the driver."""
if not self.is_connected():
Expand Down
Loading