Full systemd socket activation support

Bug #1612440 reported by Stéphane Graber on 2016-08-11
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Snapcraft
Undecided
Unassigned
snapd
Undecided
Unassigned

Bug Description

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:

sockets:
 lxd-unix:
   listen-stream: /run/lxd/unix.socket
   socket-group: lxd
   socket-mode: 0660
 lxd-tcp:
   listen-stream: [::]:8443

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.

Tags: lxd Edit Tag help
tags: added: lxd
Leo Arias (elopio) on 2017-03-19
affects: snappy → snapd
Changed in snapd:
status: New → Confirmed
Sergio Schvezov (sergiusens) wrote :

I have taken this to the forums to get more eyes on, post is here https://forum.snapcraft.io/t/socket-activation-support/2050

Alberto Donato (ack) wrote :

Link to the forum discussion about this bug: https://forum.snapcraft.io/t/socket-activation-support/2050

Alberto Donato (ack) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers