Skip to content

Conversation

lithorus
Copy link
Collaborator

@lithorus lithorus commented Jun 4, 2025

Link the Issue(s) this Pull Request is related to.
#1757 and #1735

Summarize your change.
This adds the ability to run processes using systemd-run which starts them in it's own cgroup. Logs from the process is read from journald instead of piping the output.

This should still be considered an experimental feature.

lithorus added 16 commits June 1, 2025 00:41
Introduce a new `runSystemd` method to handle frame executions using `systemd-run` under Linux. This adds features like journaling and configurable properties for better resource management. Updated logic to utilize `runSystemd` instead of `runLinux`.
Add a comment to note the need for better handling of unset environment variables or failure to connect to the systemd-daemon.
Introduce a new `RQD_USE_SYSTEMD_RUN` configuration flag to toggle between `runSystemd` and `runLinux` methods for execution on Linux systems.
Add `cysystemd` version 2.0.1 to dependencies in `pyproject.toml`. Update `rqcore.py` to utilize `cysystemd.reader` for systemd journal reading, enhancing support for systemd functionality in RQD.
Add a fallback mechanism to disable `RQD_USE_SYSTEMD_RUN` when `cysystemd` is not installed. Adjust imports dynamically to handle conditional usage of `cysystemd.reader`.
Add `import-outside-toplevel` to the pylint disable comments for `runSystemd` to address updated pylint rules.
Update `cysystemd` dependency to include a Python version constraint (`>=3.8`) in `pyproject.toml`.
…directory

Add a temporary fix to delete `/usr/local/lib64/pkgconfig` to address an issue with the 2024 image in the testing pipeline.
…11 directory

Extend the existing workaround for the 2024 image by adding steps to delete `/usr/local/lib64/python3.11`.
Simplify `cysystemd` dependency in `pyproject.toml` by removing the Python version constraint.
Move `cysystemd` to a dedicated `[systemd]` dependency group for better organization.
@lithorus lithorus changed the title Systemd run [rqd] Systemd run Jun 4, 2025
@lithorus lithorus self-assigned this Jun 4, 2025
@lithorus lithorus changed the title [rqd] Systemd run [rqd] Add systemd-run launch mode Jun 4, 2025
lithorus added 2 commits June 23, 2025 22:48
…nfig path substitution

Extend the previous workaround by removing `pkgconfig/python*.pc` and updating `_sysconfigdata__linux_x86_64-linux-gnu.py` to address path issues in the 2024 image.
@lithorus lithorus marked this pull request as ready for review June 23, 2025 23:30
Comment on lines 975 to 977
# TODO: Better handling if env vars are not set or not able to connect to the systemd-daemon
self.frameEnv['DBUS_SESSION_BUS_ADDRESS'] = os.environ['DBUS_SESSION_BUS_ADDRESS']
systemdUnitName = f"rqd-{frameInfo.frameId}.service"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please handle the case where the env is not set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Have added a check in rqconstants.py similar to checking for the python module and made the fetch safer, using .get()

self.rqCore.updateRssThread.start()

returncode = frameInfo.forkedCommand.wait()
readerThread.join()
Copy link
Collaborator

Choose a reason for hiding this comment

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

If an exception happens between the reader thread and here, you might have a thread leaked. Using a try/finally might add extra protection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, will implement that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has been added now

@DiegoTavares
Copy link
Collaborator

This looks like a good candidate to get your foot wet on rust/rqd.

@lithorus
Copy link
Collaborator Author

lithorus commented Jul 9, 2025

This looks like a good candidate to get your foot wet on rust/rqd.

Have already been looking into a good library for interacting with journald, but still haven't found one I was satisfied with.

@DiegoTavares
Copy link
Collaborator

Please document this feature before merging it in.

@lithorus lithorus marked this pull request as draft August 17, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rqd] Systemd run mode Process management bug in RQD doesn't clean inactive or de-parented processes and causes "wedged" machines.
2 participants