jesec/rtorrent

Feature request: Suport systemd notify

vamega opened this issue · 4 comments

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.

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 commented

Great idea.

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

@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 commented

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.