Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 566726 - www-servers/apache-2.4.* openrc init script - bad restart behavior
Summary: www-servers/apache-2.4.* openrc init script - bad restart behavior
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Lars Wendler (Polynomial-C) (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2015-11-24 16:32 UTC by Zoltán Halassy
Modified: 2016-03-03 16:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-apache2.initd-capture-config-test-output-in-checkcon.patch (0001-apache2.initd-capture-config-test-output-in-checkcon.patch,1.21 KB, patch)
2016-01-21 15:55 UTC, Michael Orlitzky
Details | Diff
0002-apache2.initd-remove-ancient-baselayout-1.x-check-in.patch (0002-apache2.initd-remove-ancient-baselayout-1.x-check-in.patch,981 bytes, patch)
2016-01-21 15:56 UTC, Michael Orlitzky
Details | Diff
0003-apache2.initd-update-copyright-year-to-2016.patch (0003-apache2.initd-update-copyright-year-to-2016.patch,700 bytes, patch)
2016-01-21 15:56 UTC, Michael Orlitzky
Details | Diff
0004-apache2.initd-remove-config-file-readability-check.patch (0004-apache2.initd-remove-config-file-readability-check.patch,1.81 KB, patch)
2016-01-21 15:56 UTC, Michael Orlitzky
Details | Diff
0005-apache2.initd-apply-default-values-for-conf.d-variab.patch (0005-apache2.initd-apply-default-values-for-conf.d-variab.patch,2.07 KB, patch)
2016-01-21 15:57 UTC, Michael Orlitzky
Details | Diff
0006-apache2.initd-set-the-path-to-the-apache2-binary-onc.patch (0006-apache2.initd-set-the-path-to-the-apache2-binary-onc.patch,1.20 KB, patch)
2016-01-21 15:57 UTC, Michael Orlitzky
Details | Diff
0007-apache2.initd-do-not-call-checkconfd-before-stopping.patch (0007-apache2.initd-do-not-call-checkconfd-before-stopping.patch,840 bytes, patch)
2016-01-21 15:57 UTC, Michael Orlitzky
Details | Diff
0008-apache2.initd-append-STARTUPERRORLOG-to-APACHE2_OPTS.patch (0008-apache2.initd-append-STARTUPERRORLOG-to-APACHE2_OPTS.patch,1.55 KB, patch)
2016-01-21 15:57 UTC, Michael Orlitzky
Details | Diff
0009-apache2.initd-append-SERVERROOT-and-CONFIGFILE-to-AP.patch (0009-apache2.initd-append-SERVERROOT-and-CONFIGFILE-to-AP.patch,1.48 KB, patch)
2016-01-21 15:58 UTC, Michael Orlitzky
Details | Diff
0010-apache2.initd-replace-deprecated-name-runscript-with.patch (0010-apache2.initd-replace-deprecated-name-runscript-with.patch,654 bytes, patch)
2016-01-21 15:58 UTC, Michael Orlitzky
Details | Diff
0011-apache2.initd-set-defaults-for-LYNX-and-STATUSURL-on.patch (0011-apache2.initd-set-defaults-for-LYNX-and-STATUSURL-on.patch,1.56 KB, patch)
2016-01-21 15:58 UTC, Michael Orlitzky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltán Halassy 2015-11-24 16:32:43 UTC
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
Comment 1 Zoltán Halassy 2015-11-24 16:57:42 UTC
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
Comment 2 Michael Orlitzky gentoo-dev 2015-11-25 03:58:10 UTC
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/* ?
Comment 3 Zoltán Halassy 2015-11-25 10:05:55 UTC
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.
Comment 4 Zoltán Halassy 2016-01-20 11:33:06 UTC
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
Comment 5 Michael Orlitzky gentoo-dev 2016-01-20 23:20:37 UTC
Sure enough...
Comment 6 Michael Orlitzky gentoo-dev 2016-01-21 15:24:29 UTC
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.
Comment 7 Michael Orlitzky gentoo-dev 2016-01-21 15:55:38 UTC
Created attachment 423510 [details, diff]
0001-apache2.initd-capture-config-test-output-in-checkcon.patch
Comment 8 Michael Orlitzky gentoo-dev 2016-01-21 15:56:00 UTC
Created attachment 423512 [details, diff]
0002-apache2.initd-remove-ancient-baselayout-1.x-check-in.patch
Comment 9 Michael Orlitzky gentoo-dev 2016-01-21 15:56:22 UTC
Created attachment 423514 [details, diff]
0003-apache2.initd-update-copyright-year-to-2016.patch
Comment 10 Michael Orlitzky gentoo-dev 2016-01-21 15:56:43 UTC
Created attachment 423516 [details, diff]
0004-apache2.initd-remove-config-file-readability-check.patch
Comment 11 Michael Orlitzky gentoo-dev 2016-01-21 15:57:01 UTC
Created attachment 423518 [details, diff]
0005-apache2.initd-apply-default-values-for-conf.d-variab.patch
Comment 12 Michael Orlitzky gentoo-dev 2016-01-21 15:57:21 UTC
Created attachment 423520 [details, diff]
0006-apache2.initd-set-the-path-to-the-apache2-binary-onc.patch
Comment 13 Michael Orlitzky gentoo-dev 2016-01-21 15:57:36 UTC
Created attachment 423522 [details, diff]
0007-apache2.initd-do-not-call-checkconfd-before-stopping.patch
Comment 14 Michael Orlitzky gentoo-dev 2016-01-21 15:57:53 UTC
Created attachment 423524 [details, diff]
0008-apache2.initd-append-STARTUPERRORLOG-to-APACHE2_OPTS.patch
Comment 15 Michael Orlitzky gentoo-dev 2016-01-21 15:58:13 UTC
Created attachment 423526 [details, diff]
0009-apache2.initd-append-SERVERROOT-and-CONFIGFILE-to-AP.patch
Comment 16 Michael Orlitzky gentoo-dev 2016-01-21 15:58:29 UTC
Created attachment 423528 [details, diff]
0010-apache2.initd-replace-deprecated-name-runscript-with.patch
Comment 17 Michael Orlitzky gentoo-dev 2016-01-21 15:58:46 UTC
Created attachment 423530 [details, diff]
0011-apache2.initd-set-defaults-for-LYNX-and-STATUSURL-on.patch
Comment 18 Michael Orlitzky gentoo-dev 2016-01-21 16:03:44 UTC
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.
Comment 19 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2016-01-21 17:04:27 UTC
Thanks for the patches. They look really good. I gonna add them to the apache2 git repository in a couple of days.
Comment 20 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2016-03-03 13:05:34 UTC
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.
Comment 21 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2016-03-03 16:18:28 UTC
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>