Section: systemd.socket (5)
A unit configuration file whose name ends in ".socket" encodes information about an IPC or network socket or a file system FIFO controlled and supervised by systemd, for socket-based activation.
This man page lists the configuration options specific to this unit type. See (5) for the common options of all unit configuration files. The common configuration items are configured in the generic [Unit] and [Install] sections. The socket specific configuration options are configured in the [Socket] section.
Additional options are listed in (5), which define the execution environment the ExecStartPre=, ExecStartPost=, ExecStopPre= and ExecStopPost= commands are executed in, and in (5), which define the way the processes are terminated, and in (5), which configure resource control settings for the processes of the socket.
For each socket file, a matching service file must exist, describing the service to start on incoming traffic on the socket (see (5) for more information about .service files). The name of the .service unit is by default the same as the name of the .socket unit, but can be altered with the Service= option described below. Depending on the setting of the Accept= option described below, this .service unit must either be named like the .socket unit, but with the suffix replaced, unless overridden with Service=; or it must be a template unit named the same way. Example: a socket file foo.socket needs a matching service foo.service if Accept=false is set. If Accept=true is set, a service template file [email protected] must exist from which services are instantiated for each incoming connection.
Unless DefaultDependencies= is set to false, socket units will implicitly have dependencies of type Requires= and After= on sysinit.target as well as dependencies of type Conflicts= and Before= on shutdown.target. These ensure that socket units pull in basic system initialization, and are terminated cleanly prior to system shutdown. Only sockets involved with early boot or late system shutdown should disable this option.
Socket units will have a Before= dependency on the service which they trigger added implicitly. No implicit WantedBy= or RequiredBy= dependency from the socket to the service is added. This means that the service may be started without the socket, in which case it must be able to open sockets by itself. To prevent this, an explicit Requires= dependency may be added.
Socket units may be used to implement on-demand starting of services, as well as parallelized starting of services. See the blog stories linked at the end for an introduction.
Note that the daemon software configured for socket activation with socket units needs to be able to accept sockets from systemd, either via systemd's native socket passing interface (see sd_listen_fds?(3) for details) or via the traditional inetd?(8)-style socket passing (i.e. sockets passed in via standard input and output, using StandardInput=socket in the service file).
Socket files must include a [Socket] section, which carries information about the socket or FIFO it supervises. A number of options that may be used in this section are shared with other unit types. These options are documented in (5) and (5). The options specific to the [Socket] section of socket units are the following:
ListenStream=, ListenDatagram=, ListenSequentialPacket=
If the address starts with a slash ("/"), it is read as file system socket in the AF_UNIX socket family.
If the address string is a single number, it is read as port number to listen on via IPv6. Depending on the value of BindIPv6Only= (see below) this might result in the service being available via both IPv6 and IPv4 (default) or just via IPv6.
If the address string is a string in the format v.w.x.y:z, it is read as IPv4 specifier for listening on an address v.w.x.y on a port z.
If the address string is a string in the format [x]:y, it is read as IPv6 address x on a port y. Note that this might make the service available via IPv4, too, depending on the BindIPv6Only= setting (see below).
Note that SOCK_SEQPACKET (i.e. ListenSequentialPacket=) is only available for AF_UNIX sockets. SOCK_STREAM (i.e. ListenStream=) when used for IP sockets refers to TCP sockets, SOCK_DGRAM (i.e. ListenDatagram=) to UDP.
These options may be specified more than once in which case incoming traffic on any of the sockets will trigger service activation, and all listed sockets will be passed to the service, regardless of whether there is incoming traffic on them or not. If the empty string is assigned to any of these options, the list of addresses to listen on is reset, all prior uses of any of these options will have no effect.
It is also possible to have more than one socket unit for the same service when using Service=, and the service will receive all the sockets configured in all the socket units. Sockets configured in one unit are passed in the order of configuration, but no ordering between socket units is specified.
If an IP address is used here, it is often desirable to listen on it before the interface it is configured on is up and running, and even regardless of whether it will be up and running at any point. To deal with this, it is recommended to set the FreeBind= option described below.
SmackLabel=, SmackLabelIPIn=, SmackLabelIPOut=
For more extensive descriptions see the "systemd for Developers" series: m[blue]Socket Activationm, m[blue]Socket Activation, part IIm, m[blue]Converting inetd Servicesm, m[blue]Socket Activated Internet Services and OS Containersm.
Tutoriais de Tecnologia Web