📄 stopping.html.en
字号:
<p>Users of <code class="module"><a href="./mod/mod_status.html">mod_status</a></code> will notice that the server statistics are <strong>not</strong> set to zero when a <code>USR1</code> is sent. The code was written to both minimize the time in which the server is unable to serve new requests (they will be queued up by the operating system, so they're not lost in any event) and to respect your tuning parameters. In order to do this it has to keep the <em>scoreboard</em> used to keep track of all children across generations.</p> <p>The status module will also use a <code>G</code> to indicate those children which are still serving requests started before the graceful restart was given.</p> <p>At present there is no way for a log rotation script using <code>USR1</code> to know for certain that all children writing the pre-restart log have finished. We suggest that you use a suitable delay after sending the <code>USR1</code> signal before you do anything with the old log. For example if most of your hits take less than 10 minutes to complete for users on low bandwidth links then you could wait 15 minutes before doing anything with the old log.</p> <div class="note">If your configuration file has errors in it when you issue a restart then your parent will not restart, it will exit with an error. In the case of graceful restarts it will also leave children running when it exits. (These are the children which are "gracefully exiting" by handling their last request.) This will cause problems if you attempt to restart the server -- it will not be able to bind to its listening ports. Before doing a restart, you can check the syntax of the configuration files with the <code>-t</code> command line argument (see <code class="program"><a href="./programs/httpd.html">httpd</a></code>). This still will not guarantee that the server will restart correctly. To check the semantics of the configuration files as well as the syntax, you can try starting <code class="program"><a href="./programs/httpd.html">httpd</a></code> as a non-root user. If there are no errors it will attempt to open its sockets and logs and fail because it's not root (or because the currently running <code class="program"><a href="./programs/httpd.html">httpd</a></code> already has those ports bound). If it fails for any other reason then it's probably a config file error and the error should be fixed before issuing the graceful restart.</div></div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="hup" id="hup">Restart Now</a></h2><dl><dt>Signal: HUP</dt><dd><code>apachectl -k restart</code></dd></dl> <p>Sending the <code>HUP</code> or <code>restart</code> signal to the parent causes it to kill off its children like in <code>TERM</code>, but the parent doesn't exit. It re-reads its configuration files, and re-opens any log files. Then it spawns a new set of children and continues serving hits.</p> <p>Users of <code class="module"><a href="./mod/mod_status.html">mod_status</a></code> will notice that the server statistics are set to zero when a <code>HUP</code> is sent.</p><div class="note">If your configuration file has errors in it when you issue arestart then your parent will not restart, it will exit with anerror. See above for a method of avoiding this.</div></div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="gracefulstop" id="gracefulstop">Graceful Stop</a></h2><dl><dt>Signal: WINCH</dt><dd><code>apachectl -k graceful-stop</code></dd></dl> <p>The <code>WINCH</code> or <code>graceful-stop</code> signal causes the parent process to <em>advise</em> the children to exit after their current request (or to exit immediately if they're not 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 all ports. The parent will continue to run, and monitor children which are handling requests. Once all children have finalised and exited or the timeout specified by the <code class="directive"><a href="./mod/mpm_common.html#gracefulshutdowntimeout">GracefulShutdownTimeout</a></code> has been reached, the parent will also exit. If the timeout is reached, any remaining children will be sent the <code>TERM</code> signal to force them to exit.</p> <p>A <code>TERM</code> signal will immediately terminate the parent process and all children when in the "graceful" state. However as the <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> will have been removed, you will not be able to use <code>apachectl</code> or <code>httpd</code> to send this signal.</p> <div class="note"><p>The <code>graceful-stop</code> signal allows you to run multiple identically configured instances of <code class="program"><a href="./programs/httpd.html">httpd</a></code> at the same time. This is a powerful feature when performing graceful upgrades of Apache, however it can also cause deadlocks and race conditions with some configurations.</p> <p>Care has been taken to ensure that on-disk files 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 PID, and should coexist without problem. However, if a configuration directive, third-party module or persistent CGI utilises any other on-disk lock or state files, care should be taken to ensure that multiple running instances of <code class="program"><a href="./programs/httpd.html">httpd</a></code> do not clobber each others files.</p> <p>You should also be wary of other potential race conditions, such as using <code class="program"><a href="./programs/rotatelogs.html">rotatelogs</a></code> style piped logging. Multiple running instances of <code class="program"><a href="./programs/rotatelogs.html">rotatelogs</a></code> attempting to rotate the same logfiles at the same time may destroy each other's logfiles.</p></div></div></div><div class="bottomlang"><p><span>Available Languages: </span><a href="./de/stopping.html" hreflang="de" rel="alternate" title="Deutsch"> de </a> |<a href="./en/stopping.html" title="English"> en </a> |<a href="./es/stopping.html" hreflang="es" rel="alternate" title="Espa駉l"> es </a> |<a href="./fr/stopping.html" hreflang="fr" rel="alternate" title="Fran鏰is"> fr </a> |<a href="./ja/stopping.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |<a href="./ko/stopping.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |<a href="./tr/stopping.html" hreflang="tr" rel="alternate" title="T黵k鏴"> tr </a></p></div><div id="footer"><p class="apache">Copyright 2008 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><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></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -