Skip to content
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

add dbus_systemd to handle systemctl calls #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lrusak
Copy link
Member

@lrusak lrusak commented Mar 11, 2021

Pretty self explanatory. Maybe this can be expanded in the future to make use of more or the systemd dbus API.

Could probably use some more testing to make sure the rebooting works properly.

return dbus_utils.call_method(BUS_NAME, PATH_SYSTEMD, INTERFACE_SYSTEMD_MANAGER, 'RestartUnit', name, mode)

def reboot():
return dbus_utils.call_method(BUS_NAME, PATH_SYSTEMD, INTERFACE_SYSTEMD_MANAGER, 'Reboot')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hard reboot. From https://www.freedesktop.org/software/systemd/man/org.freedesktop.systemd1.html:

Reboot(), PowerOff(), Halt(), or KExec() may be used to ask for immediate reboot, powering down, halt or kexec based reboot of the system. Note that this does not shut down any services and immediately transitions into the reboot process. These functions are normally only called as the last step of shutdown and should not be called directly. To shut down the machine, it is generally a better idea to invoke Reboot() or PowerOff() on the systemd-logind manager object; see org.freedesktop.login1(5) for more information.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that also, but I also saw this.
https://www.freedesktop.org/software/systemd/man/systemctl.html

reboot
Shut down and reboot the system. This is mostly equivalent to systemctl start reboot.target --job-
mode=replace-irreversibly --no-block, but also prints a wall message to all users. This command is asynchronous; it will return after the reboot operation is enqueued, without waiting for it to complete.

So I'm not 100% sure which we should be using. I can use the logind method if we prefer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From practice the systemd method start with:

Mar 12 23:03:56.682161 le10mars systemd[1]: Shutting down.
Mar 12 23:03:56.761798 le10mars systemd-shutdown[1]: Syncing filesystems and block devices.
Mar 12 23:03:56.761978 le10mars systemd-shutdown[1]: Sending SIGTERM to remaining processes...

what is the final step of a gracefully shutdown.

Logind can only behave better ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, it seems like the systemd direct call is too harsh. They can both be tested by the following. I'll likely change it to the logind method though.

busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Reboot
busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager Reboot b false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants