-
Notifications
You must be signed in to change notification settings - Fork 8
Retain active-state (closes #201) #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -388,7 +388,7 @@ async def _dbus_signal_loop_unit( # pylint: disable=too-many-arguments | |||||||||||||||
| unit_name=unit_name | ||||||||||||||||
| ) | ||||||||||||||||
| ((_, last_active_state),) = await unit_proxy.Get(property_name="ActiveState") | ||||||||||||||||
| await mqtt_client.publish(topic=active_state_topic, payload=last_active_state) | ||||||||||||||||
| await mqtt_client.publish(topic=active_state_topic, payload=last_active_state, retain=True) | ||||||||||||||||
| with dbus_router.filter(unit_properties_changed_match_rule) as queue: | ||||||||||||||||
| while True: | ||||||||||||||||
| await queue.get() | ||||||||||||||||
|
|
@@ -397,7 +397,7 @@ async def _dbus_signal_loop_unit( # pylint: disable=too-many-arguments | |||||||||||||||
| ) | ||||||||||||||||
| if current_active_state != last_active_state: | ||||||||||||||||
| await mqtt_client.publish( | ||||||||||||||||
| topic=active_state_topic, payload=current_active_state | ||||||||||||||||
| topic=active_state_topic, payload=current_active_state, retain=True | ||||||||||||||||
| ) | ||||||||||||||||
| last_active_state = current_active_state | ||||||||||||||||
| queue.task_done() | ||||||||||||||||
|
|
@@ -509,6 +509,13 @@ async def _run( # pylint: disable=too-many-arguments | |||||||||||||||
| payload=_MQTT_PAYLOAD_NOT_AVAILABLE, | ||||||||||||||||
| retain=True, | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| for monitored_system_unit in state.monitored_system_unit_names: | ||||||||||||||||
| await mqtt_client.publish( | ||||||||||||||||
| topic=state.get_system_unit_active_state_mqtt_topic(unit_name=monitored_system_unit), | ||||||||||||||||
| payload="unknown", | ||||||||||||||||
| retain=True, | ||||||||||||||||
| ) | ||||||||||||||||
|
Comment on lines
+512
to
+518
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I am not sure whether we should report "unknown" on the shutdown of systemctl-mqtt, as consumers should always subscribe to the birth/last-will topic
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I was really aiming for was to clear the topic of stale services. As it stands, if you decided to change what services are monitored the retained topic stays there "forever" - this was an easy way to at least mark out topics that haven't changed since shutdown. Do you think we need to clear out stale topics or leave that as an exercise of due diligence for the user?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I missed your reply. Yes, I would leave clearing the topic to the user/subscriber as we can't guarantee that "unknown" will be sent (e.g. on sigkill). |
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def _main() -> None: | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.