The runscript when called with "restart", first stops then starts the called service. In case of apache, there is a checkconfig call, when stopping with the "restart" command, then start also does a checkconfig. checkconfig unconditionally invokes checkconfd. Around the end of checkconfd, APACHE2_OPTS will be extended with -d and -f options. This happens twice when using "restart". This doesn't seem to do any problem in apache itself, but AFAIK rc-status checks status by searching for the original command line in /proc. Because of this duplication rc-status will not find the apache process, reporting it as crashed. Reproducible: Always Steps to Reproduce: # /etc/init.d/apache2 restart Actual Results: rc-status reports apache2 service as crashed, apache is invoked with double -f and -d options Expected Results: rc-status should report started, -f and -d should appear only once on the command line
The init script can be found in distfiles: gentoo-apache-2.4.10-r1-20140731.tar.bz2 gentoo-apache-2.4.10-r1/init/apache2.initd
I've been trying to reproduce this in apache-2.4.16, but I can't, even though the init scripts are the same. Even if the arguments got appended twice, openrc should be able to keep track of them since it's starting the daemon... Do you see the double args in /run/openrc/daemons/apache2/* ?
Sorry, now I cannot reproduce it neither. Altough I upgraded a lot of stuff on the system, including openrc and apache. I'll open this bug again if I'll able to reproduce the this.
Okay, I could reproduce this problem: If apache is restarted with the -D option, the problem appears. It doesn't appear without it. # /etc/init.d/apache2 -D restart
Sure enough...
I'm working on this... The problem is that openrc runs "stop" and then "start" all in one "invocation" of the init script. That calls checkconfd() twice, and appends to the variable twice. I'm just gonna clean the whole thing up.
Created attachment 423510 [details, diff] 0001-apache2.initd-capture-config-test-output-in-checkcon.patch
Created attachment 423512 [details, diff] 0002-apache2.initd-remove-ancient-baselayout-1.x-check-in.patch
Created attachment 423514 [details, diff] 0003-apache2.initd-update-copyright-year-to-2016.patch
Created attachment 423516 [details, diff] 0004-apache2.initd-remove-config-file-readability-check.patch
Created attachment 423518 [details, diff] 0005-apache2.initd-apply-default-values-for-conf.d-variab.patch
Created attachment 423520 [details, diff] 0006-apache2.initd-set-the-path-to-the-apache2-binary-onc.patch
Created attachment 423522 [details, diff] 0007-apache2.initd-do-not-call-checkconfd-before-stopping.patch
Created attachment 423524 [details, diff] 0008-apache2.initd-append-STARTUPERRORLOG-to-APACHE2_OPTS.patch
Created attachment 423526 [details, diff] 0009-apache2.initd-append-SERVERROOT-and-CONFIGFILE-to-AP.patch
Created attachment 423528 [details, diff] 0010-apache2.initd-replace-deprecated-name-runscript-with.patch
Created attachment 423530 [details, diff] 0011-apache2.initd-set-defaults-for-LYNX-and-STATUSURL-on.patch
That's it, sorry for the bugspam. Really the only thing in checkconfd() that belonged was the check for the existence of SERVERROOT. In fact, we're almost at the point where that check can be moved into checkconfig(), but we're still calling checkconfd() in configdump() and I don't know anything about those more esoteric commands so I left it alone. Now the only place we append to APACHE2_OPTS is in start(), so this bug should be fixed and I got rid of some useless junk in the process.
Thanks for the patches. They look really good. I gonna add them to the apache2 git repository in a couple of days.
I have pushed these fixes into the apache git repo. Sorry it took so long. I am planning to release the fixed init script with =www-servers/apache-2.4.18-r1 Once again thank you for providing these patches. It is highly appreciated.
commit 11d62311fe7432483fdabba794a18d59e3873e45 Author: Lars Wendler <polynomial-c@gentoo.org> Date: Thu Mar 3 17:14:55 2016 www-servers/apache: Revbump to add fixed init script (bug #566726) and added a config file for http2 module. Package-Manager: portage-2.2.27 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>