stopping.html revision 091caae3b2ebdb760c98575d0d5e349cd686f913
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
c58f1213e628a545081c70e26c6b67a841cff880vboxsync<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync BGCOLOR="#FFFFFF"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync TEXT="#000000"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync LINK="#0000FF"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync VLINK="#000080"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ALINK="#FF0000"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<!--#include virtual="header.html" -->
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<H1 ALIGN="CENTER">Stopping and Restarting Apache</H1>
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>You will notice many <CODE>httpd</CODE> executables running on your system,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncbut you should not send signals to any of them except the parent, whose
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncpid is in the <A HREF="mod/core.html#pidfile">PidFile</A>. That is to
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncsay you shouldn't ever need to send signals to any process except the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncparent. There are three signals that you can send the parent:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<CODE>TERM</CODE>, <CODE>HUP</CODE>, and <CODE>USR1</CODE>, which will
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncbe described in a moment.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>To send a signal to the parent you should issue a command such as:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncYou can read about its progress by issuing:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncModify those examples to match your
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<A HREF="mod/core.html#serverroot">ServerRoot</A> and
c7a378ed2fbad681c0b674351d698ef20a368935vboxsync<A HREF="mod/core.html#pidfile">PidFile</A> settings.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>As of Apache 1.3 we provide a script <CODE>src/support/apachectl</CODE>
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncwhich can be used to start, stop, and restart Apache. It may need a
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsynclittle customization for your system, see the comments at the top of
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>Sending the <CODE>TERM</CODE> signal to the parent causes it to
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncimmediately attempt to kill off all of its children. It may take it
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncseveral seconds to complete killing off its children. Then the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncparent itself exits. Any requests in progress are terminated, and no
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncfurther requests are served.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>Sending the <CODE>HUP</CODE> signal to the parent causes it to kill off
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncits children like in <CODE>TERM</CODE> but the parent doesn't exit. It
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncre-reads its configuration files, and re-opens any log files.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncThen it spawns a new set of children and continues
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncserving hits.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>Users of the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncwill notice that the server statistics are
941fd57f76689448d94928ce657a521e215f8671vboxsync<P><STRONG>Note:</STRONG> If your configuration file has errors in it when
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncrestart then your parent will not restart, it will exit with an error.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncSee below for a method of avoiding this.
941fd57f76689448d94928ce657a521e215f8671vboxsync<P><STRONG>Note:</STRONG> prior to release 1.2b9 this code is quite unstable
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncand shouldn't be used at all.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>The <CODE>USR1</CODE> signal causes the parent process to <EM>advise</EM>
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncthe children to exit after their current request (or to exit immediately
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncif they're not serving anything). The parent re-reads its configuration
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncfiles and re-opens its log files. As each child dies off the parent
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncreplaces it with a child from the new <EM>generation</EM> of the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncconfiguration, which begins serving new requests immediately.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>This code is designed to always respect the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<A HREF="mod/core.html#minspareservers">MinSpareServers</A>,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncand <A HREF="mod/core.html#maxspareservers">MaxSpareServers</A> settings.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncFurthermore, it respects <A HREF="mod/core.html#startservers">StartServers</A>
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncin the following manner: if after one second at least StartServers new
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncchildren have not been created, then create enough to pick up the slack.
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsyncThis is to say that the code tries to maintain both the number of children
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncappropriate for the current load on the server, and respect your wishes
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsyncwith the StartServers parameter.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>Users of the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncwill notice that the server statistics
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncare <STRONG>not</STRONG> set to zero when a <CODE>USR1</CODE> is sent. The
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncwas written to both minimize the time in which the server is unable to serve
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncnew requests (they will be queued up by the operating system, so they're
941fd57f76689448d94928ce657a521e215f8671vboxsyncnot lost in any event) and to respect your tuning parameters. In order
941fd57f76689448d94928ce657a521e215f8671vboxsyncto do this it has to keep the <EM>scoreboard</EM> used to keep track
941fd57f76689448d94928ce657a521e215f8671vboxsyncof all children across generations.
941fd57f76689448d94928ce657a521e215f8671vboxsync<P>The status module will also use a <CODE>G</CODE> to indicate those
941fd57f76689448d94928ce657a521e215f8671vboxsyncchildren which are still serving requests started before the graceful
941fd57f76689448d94928ce657a521e215f8671vboxsyncrestart was given.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<P>At present there is no way for a log rotation script using
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync<CODE>USR1</CODE> to know for certain that all children writing the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncpre-restart log have finished. We suggest that you use a suitable delay
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncafter sending the <CODE>USR1</CODE> signal before you do anything with the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncold log. For example if most of your hits take less than 10 minutes to
<!--#include virtual="footer.html" -->