github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/stopping.html.en (about)

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