~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to docs/manual/stopping.html.en

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ISO-8859-1"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
 
4
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
5
              This file is generated from xml source: DO NOT EDIT
 
6
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
7
      -->
 
8
<title>Stopping and Restarting - Apache HTTP Server</title>
 
9
<link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
 
10
<link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
 
11
<link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
 
12
<link href="./images/favicon.ico" rel="shortcut icon" /></head>
 
13
<body id="manual-page"><div id="page-header">
 
14
<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
 
15
<p class="apache">Apache HTTP Server Version 2.2</p>
 
16
<img alt="" src="./images/feather.gif" /></div>
 
17
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
 
18
<div id="path">
 
19
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>Stopping and Restarting</h1>
 
20
<div class="toplang">
 
21
<p><span>Available Languages: </span><a href="./de/stopping.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
 
22
<a href="./en/stopping.html" title="English">&nbsp;en&nbsp;</a> |
 
23
<a href="./es/stopping.html" hreflang="es" rel="alternate" title="Espa�ol">&nbsp;es&nbsp;</a> |
 
24
<a href="./ja/stopping.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
 
25
<a href="./ko/stopping.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
 
26
</div>
 
27
 
 
28
    <p>This document covers stopping and restarting Apache on
 
29
    Unix-like systems. Windows NT, 2000 and XP users should see
 
30
    <a href="platform/windows.html#winsvc">Running Apache as a
 
31
    Service</a> and Windows 9x and ME users should see <a href="platform/windows.html#wincons">Running Apache as a
 
32
    Console Application</a> for information on how to control
 
33
    Apache on those platforms.</p>
 
34
</div>
 
35
<div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#introduction">Introduction</a></li>
 
36
<li><img alt="" src="./images/down.gif" /> <a href="#term">Stop Now</a></li>
 
37
<li><img alt="" src="./images/down.gif" /> <a href="#graceful">Graceful Restart</a></li>
 
38
<li><img alt="" src="./images/down.gif" /> <a href="#hup">Restart Now</a></li>
 
39
<li><img alt="" src="./images/down.gif" /> <a href="#gracefulstop">Graceful Stop</a></li>
 
40
</ul><h3>See also</h3><ul class="seealso"><li><code class="program"><a href="./programs/httpd.html">httpd</a></code></li><li><code class="program"><a href="./programs/apachectl.html">apachectl</a></code></li><li><a href="invoking.html">Starting</a></li></ul></div>
 
41
<div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 
42
<div class="section">
 
43
<h2><a name="introduction" id="introduction">Introduction</a></h2>
 
44
 
 
45
    <p>In order to stop or restart Apache, you must send a signal to
 
46
    the running <code class="program"><a href="./programs/httpd.html">httpd</a></code> processes.  There are two ways to
 
47
    send the signals.  First, you can use the unix <code>kill</code>
 
48
    command to directly send signals to the processes. You will
 
49
    notice many <code class="program"><a href="./programs/httpd.html">httpd</a></code> executables running on your system,
 
50
    but you should not send signals to any of them except the parent,
 
51
    whose pid is in the <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code>. That is to say you
 
52
    shouldn't ever need to send signals to any process except the
 
53
    parent. There are four signals that you can send the parent:
 
54
    <code><a href="#term">TERM</a></code>,
 
55
    <code><a href="#graceful">USR1</a></code>,
 
56
    <code><a href="#hup">HUP</a></code>, and
 
57
    <code><a href="#gracefulstop">WINCH</a></code>, which
 
58
    will be described in a moment.</p>
 
59
 
 
60
    <p>To send a signal to the parent you should issue a command
 
61
    such as:</p>
 
62
 
 
63
<div class="example"><p><code>kill -TERM `cat /usr/local/apache2/logs/httpd.pid`</code></p></div>
 
64
 
 
65
    <p>The second method of signaling the <code class="program"><a href="./programs/httpd.html">httpd</a></code> processes
 
66
    is to use the <code>-k</code> command line options: <code>stop</code>,
 
67
    <code>restart</code>, <code>graceful</code> and <code>graceful-stop</code>,
 
68
    as described below.  These are arguments to the <code class="program"><a href="./programs/httpd.html">httpd</a></code> binary, but we recommend that
 
69
    you send them using the <code class="program"><a href="./programs/apachectl.html">apachectl</a></code> control script, which
 
70
    will pass them through to <code class="program"><a href="./programs/httpd.html">httpd</a></code>.</p>
 
71
 
 
72
    <p>After you have signaled <code class="program"><a href="./programs/httpd.html">httpd</a></code>, you can read about
 
73
    its progress by issuing:</p>
 
74
 
 
75
<div class="example"><p><code>tail -f /usr/local/apache2/logs/error_log</code></p></div>
 
76
 
 
77
    <p>Modify those examples to match your <code class="directive"><a href="./mod/core.html#serverroot">ServerRoot</a></code> and <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> settings.</p>
 
78
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 
79
<div class="section">
 
80
<h2><a name="term" id="term">Stop Now</a></h2>
 
81
 
 
82
<dl><dt>Signal: TERM</dt>
 
83
<dd><code>apachectl -k stop</code></dd>
 
84
</dl>
 
85
 
 
86
    <p>Sending the <code>TERM</code> or <code>stop</code> signal to
 
87
    the parent causes it to immediately attempt to kill off all of its
 
88
    children. It may take it several seconds to complete killing off
 
89
    its children.  Then the parent itself exits. Any requests in
 
90
    progress are terminated, and no further requests are served.</p>
 
91
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 
92
<div class="section">
 
93
<h2><a name="graceful" id="graceful">Graceful Restart</a></h2>
 
94
 
 
95
<dl><dt>Signal: USR1</dt>
 
96
<dd><code>apachectl -k graceful</code></dd>
 
97
</dl>
 
98
 
 
99
    <p>The <code>USR1</code> or <code>graceful</code> signal causes
 
100
    the parent process to <em>advise</em> the children to exit after
 
101
    their current request (or to exit immediately if they're not
 
102
    serving anything). The parent re-reads its configuration files and
 
103
    re-opens its log files. As each child dies off the parent replaces
 
104
    it with a child from the new <em>generation</em> of the
 
105
    configuration, which begins serving new requests immediately.</p>
 
106
 
 
107
    <p>This code is designed to always respect the process control
 
108
    directive of the MPMs, so the number of processes and threads
 
109
    available to serve clients will be maintained at the appropriate
 
110
    values throughout the restart process.  Furthermore, it respects
 
111
    <code class="directive"><a href="./mod/mpm_common.html#startservers">StartServers</a></code> in the
 
112
    following manner: if after one second at least <code class="directive"><a href="./mod/mpm_common.html#startservers">StartServers</a></code> new children have not
 
113
    been created, then create enough to pick up the slack. Hence the
 
114
    code tries to maintain both the number of children appropriate for
 
115
    the current load on the server, and respect your wishes with the
 
116
    <code class="directive"><a href="./mod/mpm_common.html#startservers">StartServers</a></code> 
 
117
    parameter.</p>
 
118
 
 
119
    <p>Users of <code class="module"><a href="./mod/mod_status.html">mod_status</a></code>
 
120
    will notice that the server statistics are <strong>not</strong>
 
121
    set to zero when a <code>USR1</code> is sent. The code was
 
122
    written to both minimize the time in which the server is unable
 
123
    to serve new requests (they will be queued up by the operating
 
124
    system, so they're not lost in any event) and to respect your
 
125
    tuning parameters. In order to do this it has to keep the
 
126
    <em>scoreboard</em> used to keep track of all children across
 
127
    generations.</p>
 
128
 
 
129
    <p>The status module will also use a <code>G</code> to indicate
 
130
    those children which are still serving requests started before
 
131
    the graceful restart was given.</p>
 
132
 
 
133
    <p>At present there is no way for a log rotation script using
 
134
    <code>USR1</code> to know for certain that all children writing
 
135
    the pre-restart log have finished. We suggest that you use a
 
136
    suitable delay after sending the <code>USR1</code> signal
 
137
    before you do anything with the old log. For example if most of
 
138
    your hits take less than 10 minutes to complete for users on
 
139
    low bandwidth links then you could wait 15 minutes before doing
 
140
    anything with the old log.</p>
 
141
 
 
142
    <div class="note">If your configuration file has errors
 
143
    in it when you issue a restart then your parent will not
 
144
    restart, it will exit with an error. In the case of graceful
 
145
    restarts it will also leave children running when it exits.
 
146
    (These are the children which are "gracefully exiting" by
 
147
    handling their last request.) This will cause problems if you
 
148
    attempt to restart the server -- it will not be able to bind to
 
149
    its listening ports. Before doing a restart, you can check the
 
150
    syntax of the configuration files with the <code>-t</code>
 
151
    command line argument (see <code class="program"><a href="./programs/httpd.html">httpd</a></code>). This still will not
 
152
    guarantee that the server will restart correctly. To check the
 
153
    semantics of the configuration files as well as the syntax, you
 
154
    can try starting <code class="program"><a href="./programs/httpd.html">httpd</a></code> as a non-root user. If there
 
155
    are no errors it will attempt to open its sockets and logs and fail
 
156
    because it's not root (or because the currently running
 
157
    <code class="program"><a href="./programs/httpd.html">httpd</a></code> already has those ports bound). If it fails
 
158
    for any other reason then it's probably a config file error and the error
 
159
    should be fixed before issuing the graceful restart.</div>
 
160
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 
161
<div class="section">
 
162
<h2><a name="hup" id="hup">Restart Now</a></h2>
 
163
 
 
164
<dl><dt>Signal: HUP</dt>
 
165
<dd><code>apachectl -k restart</code></dd>
 
166
</dl>
 
167
 
 
168
    <p>Sending the <code>HUP</code> or <code>restart</code> signal to
 
169
    the parent causes it to kill off its children like in
 
170
    <code>TERM</code>, but the parent doesn't exit. It re-reads its
 
171
    configuration files, and re-opens any log files. Then it spawns a
 
172
    new set of children and continues serving hits.</p>
 
173
 
 
174
    <p>Users of <code class="module"><a href="./mod/mod_status.html">mod_status</a></code>
 
175
    will notice that the server statistics are set to zero when a
 
176
    <code>HUP</code> is sent.</p>
 
177
 
 
178
<div class="note">If your configuration file has errors in it when you issue a
 
179
restart then your parent will not restart, it will exit with an
 
180
error. See above for a method of avoiding this.</div>
 
181
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 
182
<div class="section">
 
183
<h2><a name="gracefulstop" id="gracefulstop">Graceful Stop</a></h2>
 
184
 
 
185
<dl><dt>Signal: WINCH</dt>
 
186
<dd><code>apachectl -k graceful-stop</code></dd>
 
187
</dl>
 
188
 
 
189
    <p>The <code>WINCH</code> or <code>graceful-stop</code> signal causes
 
190
    the parent process to <em>advise</em> the children to exit after
 
191
    their current request (or to exit immediately if they're not
 
192
    serving anything). The parent will then remove its <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> and cease listening on
 
193
    all ports. The parent will continue to run, and monitor children
 
194
    which are handling requests. Once all children have finalised
 
195
    and exited or the timeout specified by the <code class="directive"><a href="./mod/mpm_common.html#gracefulshutdowntimeout">GracefulShutdownTimeout</a></code> has been
 
196
    reached, the parent will also exit.  If the timeout is reached,
 
197
    any remaining children will be sent the <code>TERM</code> signal
 
198
    to force them to exit.</p>
 
199
    
 
200
    <p>A <code>TERM</code> signal will immediately terminate the 
 
201
    parent process and all children when in the "graceful" state. However
 
202
    as the <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> will
 
203
    have been removed, you will not be able to use 
 
204
    <code>apachectl</code> or <code>httpd</code> to send this signal.</p>
 
205
 
 
206
    <div class="note"><p>The <code>graceful-stop</code> signal allows you to run multiple
 
207
    identically configured instances of <code class="program"><a href="./programs/httpd.html">httpd</a></code> at the 
 
208
    same time. This is a powerful feature when performing graceful 
 
209
    upgrades of Apache, however it can also cause deadlocks and race 
 
210
    conditions with some configurations.</p> 
 
211
 
 
212
    <p>Care has been taken to ensure that on-disk files
 
213
    such as the <code class="directive"><a href="./mod/core.html#lockfile">Lockfile</a></code> and <code class="directive"><a href="./mod/mod_cgid.html#scriptsock">ScriptSock</a></code> files contain the server
 
214
    PID, and should coexist without problem. However, if a configuration
 
215
    directive, third-party module or persistent CGI utilises any other on-disk 
 
216
    lock or  state files, care should be taken to ensure that multiple running 
 
217
    instances of <code class="program"><a href="./programs/httpd.html">httpd</a></code> do not clobber each others files.</p> 
 
218
 
 
219
    <p>You should also be wary of other potential race conditions, such as
 
220
    using <code class="program"><a href="./programs/rotatelogs.html">rotatelogs</a></code> style piped logging. Multiple running
 
221
    instances of <code class="program"><a href="./programs/rotatelogs.html">rotatelogs</a></code> attempting to rotate the same
 
222
    logfiles at the same time may destroy each other's logfiles.</p></div>
 
223
</div></div>
 
224
<div class="bottomlang">
 
225
<p><span>Available Languages: </span><a href="./de/stopping.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
 
226
<a href="./en/stopping.html" title="English">&nbsp;en&nbsp;</a> |
 
227
<a href="./es/stopping.html" hreflang="es" rel="alternate" title="Espa�ol">&nbsp;es&nbsp;</a> |
 
228
<a href="./ja/stopping.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
 
229
<a href="./ko/stopping.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
 
230
</div><div id="footer">
 
231
<p class="apache">Copyright 2006 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 
232
<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
 
233
</body></html>
 
 
b'\\ No newline at end of file'