FS#16994 - [apache] check config before reloading/restarting

Attached to Project: Arch Linux
Opened by Florian Pritz (bluewind) - Tuesday, 03 November 2009, 19:20 GMT
Last edited by Andrea Scarpino (BaSh) - Saturday, 07 November 2009, 16:18 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Andrea Scarpino (BaSh)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
If you run /etc/rc.d/httpd restart with a broken config your server terminates without any warning. Patch attached.
This task depends upon

Closed by  Andrea Scarpino (BaSh)
Saturday, 07 November 2009, 16:18 GMT
Reason for closing:  Upstream
Additional comments about closing:  https://issues.apache.org/bugzilla/show_ bug.cgi?id=45103
Comment by Andrea Scarpino (BaSh) - Tuesday, 03 November 2009, 19:39 GMT
if you restart apache with a wrong httpd.conf you get:
:: Restarting httpd daemon [FAIL]
no bug here
Comment by Florian Pritz (bluewind) - Tuesday, 03 November 2009, 19:46 GMT
extra/apache 2.2.14-1

Why doesn't that work here then?
Same output with restart btw.

> ps aux | grep http
[...]
root 759 0.7 0.1 8520 3072 pts/5 S+ 20:41 0:00 vim httpd.conf
http 17862 0.0 0.3 21372 7524 ? S Nov01 0:00 /usr/sbin/httpd -k start
> rc httpd reload
:: Reloading httpd daemon [DONE]
> ps aux | grep http
root 759 0.5 0.1 8520 3072 pts/5 S+ 20:41 0:00 vim httpd.conf
Comment by Andrea Scarpino (BaSh) - Tuesday, 03 November 2009, 19:48 GMT
I don't know but these lines are right:

/usr/sbin/apachectl restart &>/dev/null
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
add_daemon $daemon_name
stat_done
fi

apachectl return exist status=1 if httpd.conf is wrong
Comment by Florian Pritz (bluewind) - Tuesday, 03 November 2009, 19:50 GMT
> ps aux eg http
root 2427 0.2 0.1 8516 3088 pts/6 S+ 20:49 0:00 vim httpd.conf
[..]
http 2695 0.0 0.3 23120 7876 ? S 20:49 0:00 /usr/sbin/httpd -k restart
> sudo apachectl -k restart
Syntax error on line 482 of /etc/httpd/conf/httpd.conf:
Invalid command 'asasdasd', perhaps misspelled or defined by a module not included in the server configuration
> echo $?
0
> ps aux eg http
root 2427 0.2 0.1 8516 3088 pts/6 S+ 20:49 0:00 vim httpd.conf
flo 2957 0.0 0.0 4384 812 pts/7 S+ 20:50 0:00 egrep --color http
Comment by Andrea Scarpino (BaSh) - Tuesday, 03 November 2009, 20:01 GMT
$ ps aux | grep http
http 28584 0.0 0.3 20268 7124 ? S 20:54 0:00 /usr/sbin/httpd -k start
:: Restarting httpd daemon [FAIL]
$ ps aux | grep http
http 28584 0.0 0.3 20268 7124 ? S 20:54 0:00 /usr/sbin/httpd -k start

here restart fails, cause httpd.conf is wrong, but he doesn't stop apache.
Comment by Laszlo Papp (djszapi) - Saturday, 07 November 2009, 05:14 GMT
Until I set my correct http config file, it gave me [FAIL] message.

Loading...