From 9b5e8da8e3f942a9fe303081d9f246fbc24a61f1 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Thu, 26 Sep 2024 02:56:54 +0400 Subject: [PATCH] scx_loader: Add systemd service and on-DBUS launch - add ability to start loader at system start as a service - add ability to automatically launch on DBUS call whenever third-party calls the interface ref: "Example 7. DBus services" https://www.freedesktop.org/software/systemd/man/256/systemd.service.html --- rust/scx_loader/README.md | 36 +++++++++++++++++++++++++ services/systemd/meson.build | 6 +++++ services/systemd/org.scx.Loader.service | 5 ++++ services/systemd/scx_loader.service | 11 ++++++++ 4 files changed, 58 insertions(+) create mode 100644 services/systemd/org.scx.Loader.service create mode 100644 services/systemd/scx_loader.service diff --git a/rust/scx_loader/README.md b/rust/scx_loader/README.md index 71a003252..d9c7f1dad 100644 --- a/rust/scx_loader/README.md +++ b/rust/scx_loader/README.md @@ -46,6 +46,42 @@ **Note:** Replace the example scheduler names and arguments with the actual ones you want to use. +## DBUS and Systemd Service + +`scx_loader` provides the `org.scx.Loader` DBUS service and is automatically started by `dbus-daemon` when an application calls into this service. Users and administrators do not need to manually start the `scx_loader` daemon. + +`scx_loader` is managed by the `scx_loader.service` systemd unit. This service is distinct from the `scx.service` unit, which is used to manage schedulers directly (without DBUS). + +## Debugging + +In case of issues with `scx_loader`, you can debug the service using the following steps: + +1. **Check the service status:** + ```bash + systemctl status scx_loader.service + ``` + +2. **View the service logs:** + ```bash + journalctl -u scx_loader.service + ``` + +3. **Enable debug logging:** You can temporarily enable debug logging by modifying the systemd service file: + + - Edit the service file: + ```bash + sudo systemctl edit scx_loader.service + ``` + - Add the following lines under the `[Service]` section: + ``` + Environment=RUST_LOG=trace + ``` + - Restart the service: + ```bash + sudo systemctl restart scx_loader.service + ``` + - Check the logs again for detailed debugging information. + ## Development Status `scx_loader` is under active development. Future improvements may include: diff --git a/services/systemd/meson.build b/services/systemd/meson.build index 09cf499f6..b904b82dc 100644 --- a/services/systemd/meson.build +++ b/services/systemd/meson.build @@ -4,5 +4,11 @@ systemd_system_unit_dir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir # Install the 'scx.service' file to the systemd system unit directory install_data('scx.service', install_dir: systemd_system_unit_dir) +# Install the 'scx_loader.service' file to the systemd system unit directory +install_data('scx_loader.service', install_dir: systemd_system_unit_dir) + +# Install the 'org.scx.Loader.service' file to the dbus system services directory +install_data('org.scx.Loader.service', install_dir: '/usr/share/dbus-1/system-services') + # Install the 'scx' file to the '/etc/default' directory install_data('../scx', install_dir: '/etc/default') diff --git a/services/systemd/org.scx.Loader.service b/services/systemd/org.scx.Loader.service new file mode 100644 index 000000000..9ddcfe5b8 --- /dev/null +++ b/services/systemd/org.scx.Loader.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.scx.Loader +Exec=/usr/bin/scx_loader +User=root +SystemdService=scx_loader.service diff --git a/services/systemd/scx_loader.service b/services/systemd/scx_loader.service new file mode 100644 index 000000000..40bccb601 --- /dev/null +++ b/services/systemd/scx_loader.service @@ -0,0 +1,11 @@ +[Unit] +Description=DBUS on-demand loader of sched-ext schedulers + +[Service] +Type=dbus +BusName=org.scx.Loader +ExecStart=/usr/bin/scx_loader +KillSignal=SIGINT + +[Install] +WantedBy=graphical.target