]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-socket-activate.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / systemd-socket-activate.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2013 Zbigniew Jędrzejewski-Szmek
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="systemd-socket-activate"
27 xmlns:xi="http://www.w3.org/2001/XInclude">
28
29 <refentryinfo>
30 <title>systemd-socket-activate</title>
31 <productname>systemd</productname>
32
33 <authorgroup>
34 <author>
35 <contrib>Developer</contrib>
36 <firstname>Zbigniew</firstname>
37 <surname>Jędrzejewski-Szmek</surname>
38 <email>zbyszek@in.waw.pl</email>
39 </author>
40 </authorgroup>
41 </refentryinfo>
42
43 <refmeta>
44 <refentrytitle>systemd-socket-activate</refentrytitle>
45 <manvolnum>1</manvolnum>
46 </refmeta>
47
48 <refnamediv>
49 <refname>systemd-socket-activate</refname>
50 <refpurpose>Test socket activation of daemons</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <cmdsynopsis>
55 <command>systemd-socket-activate</command>
56 <arg choice="opt" rep="repeat">OPTIONS</arg>
57 <arg choice="plain"><replaceable>daemon</replaceable></arg>
58 <arg choice="opt" rep="repeat">OPTIONS</arg>
59 </cmdsynopsis>
60 </refsynopsisdiv>
61
62 <refsect1>
63 <title>Description</title>
64
65 <para><command>systemd-socket-activate</command> may be used to launch a socket-activated service program from the
66 command line for testing purposes. It may also be used to launch individual instances of the service program per
67 connection.
68 </para>
69
70 <para>The daemon to launch and its options should be specified
71 after options intended for <command>systemd-socket-activate</command>.
72 </para>
73
74 <para>If the <option>--inetd</option> option is given, the socket file descriptor will be used as the standard
75 input and output of the launched process. Otherwise, standard input and output will be inherited, and sockets will
76 be passed through file descriptors 3 and higher. Sockets passed through <varname>$LISTEN_FDS</varname> to
77 <command>systemd-socket-activate</command> will be passed through to the daemon, in the original positions. Other sockets
78 specified with <option>--listen=</option> will use consecutive descriptors. By default,
79 <command>systemd-socket-activate</command> listens on a stream socket, use <option>--datagram</option> and
80 <option>--seqpacket</option> to listen on datagram or sequential packet sockets instead (see below).
81 </para>
82 </refsect1>
83
84 <refsect1>
85 <title>Options</title>
86 <variablelist>
87 <varlistentry>
88 <term><option>-l <replaceable>address</replaceable></option></term>
89 <term><option>--listen=<replaceable>address</replaceable></option></term>
90
91 <listitem><para>Listen on this <replaceable>address</replaceable>.
92 Takes a string like <literal>2000</literal> or
93 <literal>127.0.0.1:2001</literal>.</para>
94 </listitem>
95 </varlistentry>
96
97 <varlistentry>
98 <term><option>-a</option></term>
99 <term><option>--accept</option></term>
100
101 <listitem><para>Launch an instance of the service program for each connection and pass the connection
102 socket.</para></listitem>
103 </varlistentry>
104
105 <varlistentry>
106 <term><option>-d</option></term>
107 <term><option>--datagram</option></term>
108
109 <listitem><para>Listen on a datagram socket (<constant>SOCK_DGRAM</constant>), instead of a stream socket
110 (<constant>SOCK_STREAM</constant>). May not be combined with <option>--seqpacket</option>.</para></listitem>
111 </varlistentry>
112
113 <varlistentry>
114 <term><option>--seqpacket</option></term>
115
116 <listitem><para>Listen on a sequential packet socket (<constant>SOCK_SEQPACKET</constant>), instead of a stream
117 socket (<constant>SOCK_STREAM</constant>). May not be combined with
118 <option>--datagram</option>.</para></listitem>
119 </varlistentry>
120
121 <varlistentry>
122 <term><option>--inetd</option></term>
123
124 <listitem><para>Use the inetd protocol for passing file descriptors, i.e. as standard input and standard
125 output, instead of the new-style protocol for passing file descriptors using <varname>$LISTEN_FDS</varname>
126 (see above).</para></listitem>
127 </varlistentry>
128
129 <varlistentry>
130 <term><option>-E <replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term>
131 <term><option>--setenv=<replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term>
132
133 <listitem><para>Add this variable to the environment of the
134 launched process. If <replaceable>VAR</replaceable> is
135 followed by <literal>=</literal>, assume that it is a
136 variable–value pair. Otherwise, obtain the value from the
137 environment of <command>systemd-socket-activate</command> itself.
138 </para></listitem>
139 </varlistentry>
140
141 <varlistentry>
142 <term><option>--fdname=</option><replaceable>NAME</replaceable><optional>:<replaceable>NAME</replaceable></optional></term>
143
144 <listitem><para>Specify names for the file descriptors passed. This is equivalent to setting
145 <varname>FileDescriptorName=</varname> in socket unit files, and enables use of
146 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
147 Multiple entries may be specifies using separate options or by separating names with colons
148 (<literal>:</literal>) in one option. In case more names are given than descriptors, superfluous ones will be
149 ignored. In case less names are given than descriptors, the remaining file descriptors will be unnamed.
150 </para></listitem>
151 </varlistentry>
152
153 <xi:include href="standard-options.xml" xpointer="help" />
154 <xi:include href="standard-options.xml" xpointer="version" />
155 </variablelist>
156 </refsect1>
157
158 <refsect1>
159 <title>Environment variables</title>
160 <variablelist class='environment-variables'>
161 <varlistentry>
162 <term><varname>$LISTEN_FDS</varname></term>
163 <term><varname>$LISTEN_PID</varname></term>
164 <term><varname>$LISTEN_FDNAMES</varname></term>
165
166 <listitem><para>See
167 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
168 </varlistentry>
169
170 <varlistentry>
171 <term><varname>$SYSTEMD_LOG_TARGET</varname></term>
172 <term><varname>$SYSTEMD_LOG_LEVEL</varname></term>
173 <term><varname>$SYSTEMD_LOG_COLOR</varname></term>
174 <term><varname>$SYSTEMD_LOG_LOCATION</varname></term>
175
176 <listitem><para>Same as in
177 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para></listitem>
178 </varlistentry>
179 </variablelist>
180 </refsect1>
181
182 <refsect1>
183 <title>Examples</title>
184
185 <example>
186 <title>Run an echo server on port 2000</title>
187
188 <programlisting>$ systemd-socket-activate -l 2000 --inetd -a cat</programlisting>
189 </example>
190
191 <example>
192 <title>Run a socket-activated instance of <citerefentry><refentrytitle>systemd-journal-gatewayd</refentrytitle><manvolnum>8</manvolnum></citerefentry></title>
193
194 <programlisting>$ systemd-socket-activate -l 19531 /usr/lib/systemd/systemd-journal-gatewayd</programlisting>
195 </example>
196 </refsect1>
197
198 <refsect1>
199 <title>See Also</title>
200 <para>
201 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
202 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
203 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
204 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
205 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
206 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
207 <citerefentry project='man-pages'><refentrytitle>cat</refentrytitle><manvolnum>1</manvolnum></citerefentry>
208 </para>
209 </refsect1>
210 </refentry>