1<?xml version='1.0'?> 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> 4<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> 5 6<refentry id="systemd-socket-activate" 7 xmlns:xi="http://www.w3.org/2001/XInclude"> 8 9 <refentryinfo> 10 <title>systemd-socket-activate</title> 11 <productname>systemd</productname> 12 </refentryinfo> 13 14 <refmeta> 15 <refentrytitle>systemd-socket-activate</refentrytitle> 16 <manvolnum>1</manvolnum> 17 </refmeta> 18 19 <refnamediv> 20 <refname>systemd-socket-activate</refname> 21 <refpurpose>Test socket activation of daemons</refpurpose> 22 </refnamediv> 23 24 <refsynopsisdiv> 25 <cmdsynopsis> 26 <command>systemd-socket-activate</command> 27 <arg choice="opt" rep="repeat">OPTIONS</arg> 28 <arg choice="plain"><replaceable>daemon</replaceable></arg> 29 <arg choice="opt" rep="repeat">OPTIONS</arg> 30 </cmdsynopsis> 31 </refsynopsisdiv> 32 33 <refsect1> 34 <title>Description</title> 35 36 <para><command>systemd-socket-activate</command> may be used to launch a socket-activated service program from the 37 command line for testing purposes. It may also be used to launch individual instances of the service program per 38 connection. 39 </para> 40 41 <para>The daemon to launch and its options should be specified 42 after options intended for <command>systemd-socket-activate</command>. 43 </para> 44 45 <para>If the <option>--inetd</option> option is given, the socket file descriptor will be used as the standard 46 input and output of the launched process. Otherwise, standard input and output will be inherited, and sockets will 47 be passed through file descriptors 3 and higher. Sockets passed through <varname>$LISTEN_FDS</varname> to 48 <command>systemd-socket-activate</command> will be passed through to the daemon, in the original positions. Other sockets 49 specified with <option>--listen=</option> will use consecutive descriptors. By default, 50 <command>systemd-socket-activate</command> listens on a stream socket, use <option>--datagram</option> and 51 <option>--seqpacket</option> to listen on datagram or sequential packet sockets instead (see below). 52 </para> 53 </refsect1> 54 55 <refsect1> 56 <title>Options</title> 57 <variablelist> 58 <varlistentry> 59 <term><option>-l <replaceable>address</replaceable></option></term> 60 <term><option>--listen=<replaceable>address</replaceable></option></term> 61 62 <listitem><para>Listen on this <replaceable>address</replaceable>. 63 Takes a string like <literal>2000</literal> or 64 <literal>127.0.0.1:2001</literal>.</para> 65 </listitem> 66 </varlistentry> 67 68 <varlistentry> 69 <term><option>-a</option></term> 70 <term><option>--accept</option></term> 71 72 <listitem><para>Launch an instance of the service program for each connection and pass the connection 73 socket.</para></listitem> 74 </varlistentry> 75 76 <varlistentry> 77 <term><option>-d</option></term> 78 <term><option>--datagram</option></term> 79 80 <listitem><para>Listen on a datagram socket (<constant>SOCK_DGRAM</constant>), instead of a stream socket 81 (<constant>SOCK_STREAM</constant>). May not be combined with <option>--seqpacket</option>.</para></listitem> 82 </varlistentry> 83 84 <varlistentry> 85 <term><option>--seqpacket</option></term> 86 87 <listitem><para>Listen on a sequential packet socket (<constant>SOCK_SEQPACKET</constant>), instead of a stream 88 socket (<constant>SOCK_STREAM</constant>). May not be combined with 89 <option>--datagram</option>.</para></listitem> 90 </varlistentry> 91 92 <varlistentry> 93 <term><option>--inetd</option></term> 94 95 <listitem><para>Use the inetd protocol for passing file descriptors, i.e. as standard input and standard 96 output, instead of the new-style protocol for passing file descriptors using <varname>$LISTEN_FDS</varname> 97 (see above).</para></listitem> 98 </varlistentry> 99 100 <varlistentry> 101 <term><option>-E <replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term> 102 <term><option>--setenv=<replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term> 103 104 <listitem><para>Add this variable to the environment of the 105 launched process. If <replaceable>VAR</replaceable> is 106 followed by <literal>=</literal>, assume that it is a 107 variable–value pair. Otherwise, obtain the value from the 108 environment of <command>systemd-socket-activate</command> itself. 109 </para></listitem> 110 </varlistentry> 111 112 <varlistentry> 113 <term><option>--fdname=</option><replaceable>NAME</replaceable><optional>:<replaceable>NAME</replaceable>…</optional></term> 114 115 <listitem><para>Specify names for the file descriptors passed. This is equivalent to setting 116 <varname>FileDescriptorName=</varname> in socket unit files, and enables use of 117 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>. 118 Multiple entries may be specifies using separate options or by separating names with colons 119 (<literal>:</literal>) in one option. In case more names are given than descriptors, superfluous ones will be 120 ignored. In case less names are given than descriptors, the remaining file descriptors will be unnamed. 121 </para></listitem> 122 </varlistentry> 123 124 <xi:include href="standard-options.xml" xpointer="help" /> 125 <xi:include href="standard-options.xml" xpointer="version" /> 126 </variablelist> 127 </refsect1> 128 129 <refsect1> 130 <title>Environment variables</title> 131 <variablelist class='environment-variables'> 132 <varlistentry> 133 <term><varname>$LISTEN_FDS</varname></term> 134 <term><varname>$LISTEN_PID</varname></term> 135 <term><varname>$LISTEN_FDNAMES</varname></term> 136 137 <listitem><para>See 138 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem> 139 </varlistentry> 140 141 <varlistentry> 142 <term><varname>$SYSTEMD_LOG_TARGET</varname></term> 143 <term><varname>$SYSTEMD_LOG_LEVEL</varname></term> 144 <term><varname>$SYSTEMD_LOG_TIME</varname></term> 145 <term><varname>$SYSTEMD_LOG_COLOR</varname></term> 146 <term><varname>$SYSTEMD_LOG_LOCATION</varname></term> 147 148 <listitem><para>Same as in 149 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para></listitem> 150 </varlistentry> 151 </variablelist> 152 </refsect1> 153 154 <refsect1> 155 <title>Examples</title> 156 157 <example> 158 <title>Run an echo server on port 2000</title> 159 160 <programlisting>$ systemd-socket-activate -l 2000 --inetd -a cat</programlisting> 161 </example> 162 163 <example> 164 <title>Run a socket-activated instance of <citerefentry><refentrytitle>systemd-journal-gatewayd</refentrytitle><manvolnum>8</manvolnum></citerefentry></title> 165 166 <programlisting>$ systemd-socket-activate -l 19531 /usr/lib/systemd/systemd-journal-gatewayd</programlisting> 167 </example> 168 </refsect1> 169 170 <refsect1> 171 <title>See Also</title> 172 <para> 173 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 174 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, 175 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, 176 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 177 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 178 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 179 <citerefentry project='man-pages'><refentrytitle>cat</refentrytitle><manvolnum>1</manvolnum></citerefentry> 180 </para> 181 </refsect1> 182</refentry> 183