Bug 45103 - apachectl should do config test before reload/restart, according to documentation, but it doesn't
Summary: apachectl should do config test before reload/restart, according to documenta...
Status: ASSIGNED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: support (show other bugs)
Version: 2.5-HEAD
Hardware: Other Linux
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-30 10:03 UTC by Stefan Fritsch
Modified: 2008-09-02 15:49 UTC (History)
1 user (show)



Attachments
Fixes behaviour of apachectl to run configtest before starting server, as per doc (644 bytes, patch)
2008-09-02 11:53 UTC, Matthew Hodgson
Details | Diff
Perform configtest in apachectl (only) before restarting the httpd (631 bytes, patch)
2008-09-02 15:49 UTC, Matthew Hodgson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Fritsch 2008-05-30 10:03:55 UTC
From
http://httpd.apache.org/docs/2.2/programs/apachectl.html :

"This command automatically checks the configuration files as in configtest before initiating the restart to make sure Apache doesn't die. This is equivalent to apachectl -k graceful."

But apachectl doesn't do a config test. Either apachectl or the documentation should be changed.
Comment 1 Takashi Sato 2008-05-30 10:45:30 UTC
You specified Version as "2.3-HEAD", but the URL you wrote was 2.2 docs.
Yes, as I understand 2.2 apachectl doesn't do config test before graceful restart. So there is a bug.
How about trunk(2.3) ?
Comment 2 Takashi Sato 2008-05-30 10:50:02 UTC
http://httpd.apache.org/docs/trunk/en/stopping.html
When you issue a restart, a syntax check is first run, to ensure that there are no errors in the configuration files. If your configuration file has errors in it, you will get an error message about that syntax error, and the server will refuse to restart. This avoids the situation where the server halts and then cannot restart, leaving you with a non-functioning server.


http://httpd.apache.org/docs/2.2/en/stopping.html
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.
Comment 3 Stefan Fritsch 2008-05-30 11:19:47 UTC
(In reply to comment #1)
> You specified Version as "2.3-HEAD", but the URL you wrote was 2.2 docs.
> Yes, as I understand 2.2 apachectl doesn't do config test before graceful
> restart. So there is a bug.
> How about trunk(2.3) ?
> 

As far as I can see, trunk's apachectl does no config test either. Therefore I chose 2.3-HEAD.
Comment 4 Matthew Hodgson 2008-09-02 10:16:27 UTC
The current trunk (2.3) documentation at http://httpd.apache.org/docs/trunk/en/stopping.html states:

"As with a graceful restart, a syntax check is run before the restart is attempted. If your configuration file has errors in it, the restart will not be attempted, and you will receive notification of the syntax error(s)."

As far as I can see, support in apachectl for running a configtest before a restart was removed in r95307 ('simplified apachectl...'): http://svn.apache.org/viewvc/httpd/httpd/trunk/support/apachectl.in?r1=94653&r2=95307

Is there any good reason for apachectl to not test the config before restarting?  Anyone used to the 1.3 behaviour could be very seriously affected by this regression - not least the contradictory documentation.
Comment 5 Matthew Hodgson 2008-09-02 11:53:34 UTC
Created attachment 22517 [details]
Fixes behaviour of apachectl to run configtest before starting server, as per doc

Attached is a patch against trunk to fix apachectl such that it runs configtest before restarting a running server.  This matches the behaviour described in the documentation, and the behaviour expected under Apache 1.3, and significantly reduces the chances of you being left without a running server after accidentally redeploying on a broken config.
Comment 6 Matthew Hodgson 2008-09-02 15:49:10 UTC
Created attachment 22518 [details]
Perform configtest in apachectl (only) before restarting the httpd

Actually, this refines the previous patch to only sanity-check the config before restarting the httpd - if you're starting a new one you obviously get a configtest for free without any disadvantages.