Search code examples
systemd

systemd socket service that connects?


Is it possible to create a systemd socket service that connects to a socket on startup?

The systemd.socket documentation (https://www.freedesktop.org/software/systemd/man/systemd.socket.html) contains no mention of it so I doubt it's possible, but it sure would be nice.

Specifically I want a service that has its stdout set to a connect()ed UNIX socket so I can opportunistically use sendmsg for extra data when connected to another service. I can do this myself or with arguments, but it would simplify my application if I didn't have to.


Solution

  • Yes I can!

    I need to use StandardOut=file:/path/to/unix-socket

    Which is documented in: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#