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

Feature request: Suport systemd notify #39

Open
vamega opened this issue May 20, 2022 · 4 comments
Open

Feature request: Suport systemd notify #39

vamega opened this issue May 20, 2022 · 4 comments

Comments

@vamega
Copy link

vamega commented May 20, 2022

Would you be open to accepting a patch that lets rtorrent notify systemd when it is ready?
This would allow writing of systemd service files that start flood/rutorrent after rtorrent has started up.

The systemd service type would switch to Type=notify.

Assuming you're okay with this, my plan would be the following.

I'm thinking I'll have this behind a configure flag, since the simplest approach would involve calling sd_notify. -DUSE_SYSTEMD seems like the reasonable flag for CMake.

I'm less familiar with Bazel, any pointers to how to support a build option like that with Bazel would be appreciated.

@kannibalox
Copy link
Contributor

Not to say that having it directly in the code wouldn't be useful, but you can already accomplish your goal with the available event bindings and systemd-notify:

# Startup
method.set_key = event.system.startup_done, notify_systemd, "execute=/bin/systemd-notify,--ready,--status,(cat,SESSION=,(session.name)),--pid,(system.pid)"
# Shutdown
method.set_key = event.system.shutdown, notify_systemd, "execute=/bin/systemd-notify,STOPPING=1"

@jesec
Copy link
Owner

jesec commented May 21, 2022

Great idea.

I don't want the binary to link against libsystemd, though. Is there a standalone solution?

@vamega
Copy link
Author

vamega commented May 21, 2022

@kannibalox thanks I wasn’t aware of that. Should have looked at the configuration options more closely.

@jesec I could probably make this work by opening a Unix datagtam socket and sending the data myself.

Is there a reason you’re opposed to linking against systemd?

@jesec
Copy link
Owner

jesec commented May 21, 2022

Not all systems have systemd or libsystemd. You may find this useful: https://github.com/lnicola/sd-notify.

i knew this project is not in Rust, but you can check out the logic.

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

No branches or pull requests

3 participants