Debian Codegraph @

doc/howto/Stopping.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: Stopping and Starting</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b><i>ProFTPD: Stopping and Starting</i></b></h2></center>
11 <hr>
12
13 <p>
14 The starting and stopping of a ProFTPD server is a straightforward process,
15 once the means intended for such things are understood. Starting the
16 server is easy. Stopping and/or restarting the server are the more complicated
17 tasks. Stopping and/or restarting can be accomplish either using signals or
18 <code>ftpshut</code>, depending on your needs. Use of signals will fulfill
19 most requirements; the <code>ftpshut</code> program is used for a
20 <a href="#ftpshut">specific way of shutting down</a> a <code>proftpd</code>
21 server.
22
23 <p><a name="Starting"></a>
24 <b>Starting <code>proftpd</code></b><br>
25 The <a href="ServerType.html"><code>ServerType</code></a> configured in
26 your <code>proftpd.conf</code> determines how you should start your
27 <code>proftpd</code> daemon. A <code>ServerType</code> of "inetd" means
28 that you are letting inetd/xinetd handle the starting of the server; using
29 "standalone" means that you will probably end up using some kind of
30 script (<i>e.g.</i> <code>init.d</code> shell scripts).
31
32 <p>
33 All start scripts end up using, in some form or another, the various
34 command-line options supported by <code>proftpd</code>:
35 <pre>
36 /usr/local/sbin/proftpd [options]
37 </pre>
38 where <code>/usr/local/sbin</code> is determined by <code>configure</code>
39 and <code>[options]</code> are described below (or in <em>proftpd(8)</em>):
40 <pre>
41 -h, --help
42 Display proftpd usage
43 -n, --nodaemon
44 Disable background daemon mode and send all output to stderr)
45 -q, --quiet
46 Don't send output to stderr when running with -n or --nodaemon
47 -d [level], --debug
48 Set debugging level (0-9, 9 = most debugging)
49 -D [definition], --define
50 Set arbitrary IfDefine definition
51 -c [config-file], --config
52 Specify alternate configuration file
53 -p [0|1], --persistent
54 Enable/disable default persistent passwd support
55 -l, --list
56 List all compiled-in modules
57 -t, --configtest
58 Test the syntax of the specified config
59 -v, --version
60 Print version number and exit
61 -vv, --version-status
62 Print extended version information and exit
63 </pre>
64
65 <p><a name="Signals"></a>
66 <b>Signals</b><br>
67 You will notice many <code>proftpd</code> processes running on your system,
68 but you should not send signals to any of them except the parent, whose PID is
69 in the <code>PidFile</code>. That is to say, you should not ever need to
70 send signals to any process except the parent. There are two signals that you
71 can send the parent: <code>TERM</code> and <code>HUP</code>, which will be
72 described below.
73
74 <!--
75 <GeekBoy> timeouts left child processes going... I kill -9 both of them and it proceeds to tell me max num of allowed clients are connected
76 <castaglia> don't use -9
77 <GeekBoy> hmmmm, ok
78 <castaglia> there's no way proftpd can handle killed sessions if you use -9
79 <GeekBoy> let's try this again
80 <castaglia> no app can
81 <castaglia> if you need to kill a session
82 <GeekBoy> was unaware of the low level workings of the various kill signals
83 <castaglia> just use 'kill <pid>'
84 <castaglia> -9 is SIGKILL
85 <GeekBoy> ok
86 <castaglia> and an application cannot catch or handle that particular signal
87 <castaglia> the kernel will not allow it
88 <castaglia> as that one signal is reserved, to make sure that the kernel can use it to kill any process
89 <castaglia> as when the server is shutting down
90 <GeekBoy> ok
91 <castaglia> unfortunately, it also means that the application can't catch the -9 and do any proper cleanup
92 <castaglia> imho, people use -9 too much these days
93 <GeekBoy> i see
94 <GeekBoy> I'll avoid using it when the default doesn't work
95 <GeekBoy> which is 15, right?
96 <castaglia> ummm...yes
97 <castaglia> SIGTERM
98 -->
99
100 <p>
101 To send a signal to the parent you should issue a command such as:
102 <pre>
103 kill -TERM `cat /usr/local/var/proftpd.pid`
104 </pre>
105 You can read about its progress by issuing:
106 <pre>
107 tail -f /usr/local/var/logs/proftpd.log
108 </pre>
109 Modify those examples to match your <code>SystemLog</code> and
110 <code>PidFile</code> settings.
111
112 <p>
113 <b>The <code>TERM</code> Signal</b> <i>(stop now)</i><br>
114 Sending the <code>TERM</code> signal to the daemon parent process causes it
115 to immediately attempt to kill off all of its children. It may take it several
116 seconds to complete killing off its children. The daemon itself then exits.
117 Any transfers in progress are terminated, and no further session requests
118 are served.
119
120 <p>
121 Servers run out of <code>inetd</code> or <code>xinetd</code> (<i>e.g.</i> with
122 a <code>ServerType</code> setting of <code>inetd</code>) will not need this
123 signal, as their &quot;parent&quot; is the <code>inetd</code> or
124 <code>xinetd</code> process.
125
126 <p>
127 <b>The <code>HUP</code> Signal</b> <i>(restart now)</i><br>
128 Sending the <code>HUP</code> signal to the daemon parent process causes it to
129 re-read its configuration file(s), and re-opens any log files. Then it
130 returns to handling new sessions. Any existing sessions will <b>not</b>
131 be terminated.
132
133 <p>
134 Servers run out of <code>inetd</code> or <code>xinetd</code> will not need
135 this signal; a new server process is started by the superserver process
136 (<i>e.g.</i> <code>inetd</code> or <code>xinetd</code>) for every session
137 request. This means that any changes to the configuration file will be
138 visible to the next session after saving the changes to the file.
139
140 <p>
141 Note that if your configuration file has errors in it when you issue a restart
142 then your parent will not restart, it will exit with an error. To avoid this,
143 perform a syntax check of the file before sending the signal:
144 <pre>
145 proftpd -t -d5
146 </pre>
147
148 <p><a name="InitScripts"></a>
149 <b>Example <code>init.d</code> script</b><br>
150 If your particular Unix/Linux distribution and/or <code>proftpd</code>
151 package does not provide an init shell script for <code>proftpd</code>, or
152 you want to write your own, here is a simple example script to demonstrate
153 what one would look like:
154 <pre>
155 #!/bin/sh
156
157 # ProFTPD files
158 FTPD_BIN=/usr/local/sbin/proftpd
159 FTPD_CONF=/usr/local/etc/proftpd.conf
160 PIDFILE=/var/run/proftpd.pid
161
162 # If PIDFILE exists, does it point to a proftpd process?
163
164 if [ -f $PIDFILE ]; then
165 pid=`cat $PIDFILE`
166 fi
167
168 if [ ! -x $FTPD_BIN ]; then
169 echo "$0: $FTPD_BIN: cannot execute"
170 exit 1
171 fi
172
173 case $1 in
174
175 start)
176 if [ -n "$pid" ]; then
177 echo "$0: proftpd [PID $pid] already running"
178 exit
179 fi
180
181 if [ -r $FTPD_CONF ]; then
182 echo "Starting proftpd..."
183
184 $FTPD_BIN -c $FTPD_CONF
185
186 else
187 echo "$0: cannot start proftpd -- $FTPD_CONF missing"
188 fi
189 ;;
190
191 stop)
192 if [ -n "$pid" ]; then
193 echo "Stopping proftpd..."
194 kill -TERM $pid
195
196 else
197 echo "$0: proftpd not running"
198 exit 1
199 fi
200 ;;
201
202 restart)
203 if [ -n "$pid" ]; then
204 echo "Rehashing proftpd configuration"
205 kill -HUP $pid
206
207 else
208 echo "$0: proftpd not running"
209 exit 1
210 fi
211 ;;
212
213 *)
214 echo "usage: $0 {start|stop|restart}"
215 exit 1
216 ;;
217
218 esac
219
220 exit 0
221 </pre>
222
223 <p>
224 For Mac OSX users, here is an example Launcher/launchd <code>plist</code>
225 configuration for <code>proftpd</code>:
226 <pre>
227 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
228 &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
229 &lt;plist version="1.0"&gt;
230 &lt;dict&gt;
231 &lt;key&gt;KeepAlive&lt;/key&gt;
232 &lt;dict&gt;
233 &lt;key&gt;SuccessfulExit&lt;/key&gt;
234 &lt;true/&gt;
235 &lt;/dict&gt;
236 &lt;key&gt;Label&lt;/key&gt;
237 &lt;string&gt;org.proftpd.proftpd&lt;/string&gt;
238 &lt;key&gt;ProgramArguments&lt;/key&gt;
239 &lt;array&gt;
240 &lt;string&gt;/usr/local/sbin/proftpd&lt;/string&gt;
241 &lt;string&gt;-n&lt;/string&gt;
242 &lt;/array&gt;
243 &lt;key&gt;RunAtLoad&lt;/key&gt;
244 &lt;true/&gt;
245 &lt;key&gt;ServiceIPC&lt;/key&gt;
246 &lt;false/&gt;
247 &lt;/dict&gt;
248 &lt;/plist&gt;
249 </pre>
250 This has been reported to run successfully on Mac OSX 10.4 and 10.5.
251
252 <p>
253 <a name="ftpshut"><b>The <code>ftpshut</code> program</b><br>
254 The <code>ftpshut</code> program that comes as part of ProFTPD can also
255 be used to shut down a <code>proftpd</code> server, in a sense. This program
256 does not actually cause the server to stop completely, but rather places
257 the server in an &quot;administrative shutdown&quot; state. This means
258 that the server will still be handling session requests, but will deny
259 incoming requests, telling clients to come back later. <code>ftpshut</code>
260 allows the administrator to configure the server to start refusing
261 connections at some future date, and also to disconnect existing sessions
262 at some future date.
263
264 <p>
265 The situation in which this ability is most useful (a
266 <a href="http://www.proftpd.org/docs/faq/proftpdfaq-4.html#ss4.17">FAQ</a>) is
267 one where filesystem maintainenance or work needs to be done in the area from
268 which the FTP server is serving files, but the server need not be shutdown.
269 By placing the server in an &quot;administrative shutdown&quot; mode, clients
270 are barred from their file while the administrative work is being done. Once
271 completed, the server can be put back in normal operating mode by simply
272 deleting the shutdown message file, described below.
273
274 <p>
275 The <code>ftpshut</code> program works by creating a file, usually
276 <code>/etc/shutmsg</code>, for which the server checks periodically. This
277 file will contain the time at which the server is to place itself in
278 &quot;administrative shutdown&quot; mode, and times (if any) of refusing
279 incoming connections, disconnecting existing connections. Unfortunately,
280 many third-party administration tools use <code>ftpshut</code> to shut
281 down <code>proftpd</code> servers, rather than using the method above. The
282 problem with this approach is that, once restarted, the server will check
283 for <code>/etc/shutmsg</code>, and will not accept incoming connections,
284 leading to this
285 <a href="http://www.proftpd.org/docs/faq/faq_full.html#AEN373">FAQ</a>;
286 the third-party administration tool often forgets to delete that file once
287 done.
288
289 <p>
290 Read <code>ftpshut</code>'s
291 <a href="../utils/ftpshut.html">man</a> page for more detailed information on
292 its usage.
293
294 <p>
295 <hr>
296 <font size=2><b><i>
297 &copy; Copyright 2017 The ProFTPD Project<br>
298 All Rights Reserved<br>
299 </i></b></font>
300 <hr>
301
302 </body>
303 </html>