Full systemd socket activation support
For the LXD snap we'd like to use socket activation, similarly to what
we do in our existing packages.
This is used to save resources on machines until LXD is actually used
and also to allow flexibility as far as the sockets (unix or tcp) that
will point to LXD.
This is all supported by systemd. Ideally we'd like to have a way to use
the following features through snapd and snapcraft:
- Support for multiple sockets triggering the same service
- Support for ListenStream (supports unix sockets, abstract unix sockets and tcp)
- Support for SocketGroup (group owner of the socket created by systemd)
- Support for SocketMode (file mode of the socket created by systemd)
I would probably recommend also adding SocketUser just for consistency.
It's the same logic as Socketgroup but sets the owning user (or uid).
The current implementation in snapd is done with two options on the app:
- socket (boolean, requires listen-stream)
- listen-stream (the systemd listen-stream string)
This should probably be changed to something more like:
That would lead to the creation of two systemd socket units, one for
each socket, using the provided options and pointing to the service unit
defined for the app.
When sockets are defined, I would expect snapd NOT to start the service
unit, leaving things up to systemd socket activation.
Systemd provides a lot more options around socket activation, but the
ones above are the most commonly used ones. The others tend to be around
less common socket types, special socket options and pre/post actions.