-
Notifications
You must be signed in to change notification settings - Fork 139
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
Avoid system calls to interact with systemd services #2680
Comments
This looks interesting and seems to allow for simplification from constructing the commands for systemd to a simpler way! Would this come before or after below design decision? #2650 (Replace supervisord with further systemd intergration) In my mind this would probably come before further moving items into the systemd realm, so the transition would be simpler, too. Or am I connecting two things that are really independent? |
That's something we'll have to verify, indeed. I'm thinking the same as you so far. I have only briefly tried with restarting the
Very good point. My first thought is that it shouldn't really matter as I'm hoping we can "simply" change our current wrappers around |
As mentioned in #2768 (comment), installing
This is in line with |
@FroggyFlox Re:
Is this not just a system (Leap) package that we require to be installed? |
Absolutely. I forgot that I had already tried and tested
|
We currently use a lot of system calls via
run_command()
(a wrapper aroundsubprocess.Popen()
) to interact with various systemd units. Seesystem.services.py
for a very good list of examples. This is very cumbersome to operate, heavy to parse the outputs, and most likely rather wasteful.A better approach would most likely be to directly interact with systemd DBus. While we already have the
dbus
library as a dependency for interacting with the SSSD DBus responder InfoPipe, there is a python library to simplify interacting with systemd units and services:pystemd
GitHub: https://github.com/systemd/pystemd
Their description seems to fit our needs exactly:
The project is hosted by the
systemd
organization on Github, and seems actively maintained (https://github.com/systemd/pystemd/releases). It is also easily available on PyPI.org, making it easy to be added to ourpyproject.toml
.It is licensed LGPL-2.1: https://github.com/systemd/pystemd/blob/main/LICENSE
It is currently supporting Python3.6 and later.
Note that to build it, we would need to following new system package:
systemd-devel
.An example use on how to restart a service is described at systemd/pystemd#60 (comment)
It would allow us to access all properties and methods described at https://www.freedesktop.org/software/systemd/man/org.freedesktop.systemd1.html#Properties1
The text was updated successfully, but these errors were encountered: