Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 388009 - www-servers/apache-2.2.21-r1 init scripts fails
Summary: www-servers/apache-2.2.21-r1 init scripts fails
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Patrick Lauer
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 14:47 UTC by Marcin Mirosław
Modified: 2013-02-28 21:16 UTC (History)
6 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Mirosław 2011-10-21 14:47:11 UTC
I'm often getting such messages when trying to restart apache:
# /etc/init.d/apache2 restart
 * Stopping apache2 ...                                                                                                                                         [ ok ]
 * Starting apache2 ...
 * start-stop-daemon: /usr/sbin/apache2 is already running                                                                                                      [ ok ]

Ok, once again:
# /etc/init.d/apache2 restart
 * apache2 not running (no pid file)
 * Starting apache2 ...  

And i'm getting console after TIMEOUT seconds. Apache is working at this moment.
I suspect problem appears when apache is working some time, and doesn't quit immediatelly.


Reproducible: Sometimes
Comment 1 Peter Volkov (RETIRED) gentoo-dev 2011-10-24 08:53:21 UTC
Thank you for report, Marcin. Probably I see the reason...

Could you check that init script on your system has the code:

        i=0
        while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \
                && [ $i -lt ${TIMEOUT} ]; do
                sleep 1 && i=$(expr $i + 1)
        done

        eend $(test $i -lt ${TIMEOUT})

I guess we need to modify 
while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \
into
while ( ! test -f "${PIDFILE}" || pgrep -P ${PID} apache2 >/dev/null ) \
... at least this is what was supposed. BTW what MPM do you use?
Comment 2 Marcin Mirosław 2011-10-24 09:05:43 UTC
I'm using prefork MPM. I did one test, works better (aka apache was restarted without problem). Please give me a couple of days to do more tests.
Comment 3 Marcin Mirosław 2011-10-26 07:55:25 UTC
It looks init scripts do its job correctly.
Comment 4 Dirkjan Ochtman (RETIRED) gentoo-dev 2011-10-26 15:17:54 UTC
I'm having similar problems, with the worker MPM; it's a pretty annoying regression.
Comment 5 David Oberlitner 2011-10-26 22:22:03 UTC
(In reply to comment #1)
> Thank you for report, Marcin. Probably I see the reason...
> 
> Could you check that init script on your system has the code:
> 
>         i=0
>         while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null )
> \
>                 && [ $i -lt ${TIMEOUT} ]; do
>                 sleep 1 && i=$(expr $i + 1)
>         done
> 
>         eend $(test $i -lt ${TIMEOUT})
> 
> I guess we need to modify 
> while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \
> into
> while ( ! test -f "${PIDFILE}" || pgrep -P ${PID} apache2 >/dev/null ) \
> ... at least this is what was supposed. BTW what MPM do you use?

The change outlined above worked for me!
Comment 6 Matthew Schultz 2011-10-28 14:59:56 UTC
I'm having the same problem with the init script.  Although 2.2.21 used deprecated calls, apache restart worked fine but it no longer restarts properly with 2.2.21-r1.  This is a regression.
Comment 7 Matthew Schultz 2011-10-28 15:13:32 UTC
(In reply to comment #1)
> I guess we need to modify 
> while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \
> into
> while ( ! test -f "${PIDFILE}" || pgrep -P ${PID} apache2 >/dev/null ) \
> ... at least this is what was supposed. BTW what MPM do you use?


The switch to logical OR worked for me as well.  I use worker MPM.
Comment 8 Philip Taffner 2011-10-28 21:50:30 UTC
The "||-fix" worked for me, too.
I'm using the itk MPM.
Comment 9 csefko 2011-11-19 16:05:01 UTC
The fix (&& -> ||) works fine. Can you please fix it?
Comment 10 Milos Ivanovic 2011-12-05 22:08:13 UTC
I beg to differ. The switch to logical OR works, but waits until ${TIMEOUT} seconds before restarting. I don't think that's a solution. If I'm wrong please correct me, but some changes in bug 389965 might work better.
Comment 11 Marcin Mirosław 2011-12-12 15:45:38 UTC
Ping.
Comment 12 Marcin Mirosław 2012-01-10 08:58:28 UTC
Hmm, apache isn't rarely using soft, what is the reason of such huge delay with rather simple fix?
Comment 13 Patrick Lauer gentoo-dev 2012-03-28 15:05:48 UTC
+  28 Mar 2012; Patrick Lauer <patrick@gentoo.org> +apache-2.2.22.ebuild:
+  Bump for #401761. init script fix for #389965
Comment 14 Marcin Mirosław 2012-03-28 15:08:59 UTC
Thanks.
Comment 15 Toralf Förster gentoo-dev 2012-03-28 17:34:43 UTC
For me only this works :

while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null )
Comment 16 Gerrit Helm 2012-03-29 04:08:49 UTC
(In reply to comment #15)
> For me only this works :
> 
> while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null )

The fix (https://bugs.gentoo.org/attachment.cgi?id=293073&action=diff) in #389965 was tested on several machines with no problems so far.

Did you already try it?
Comment 17 Patrick Lauer gentoo-dev 2012-03-29 15:31:37 UTC
Should be fixed now, reopen if you still can make it fail
Comment 18 Marcin Mirosław 2012-04-27 11:20:57 UTC
It looks it still somethings is going bad:

# /etc/init.d/apache2 restart
 * Caching service dependencies ...                                                                                                                     [ ok ]
 * Stopping apache2 ...                                                                                                                                 [ ok ]
 * Starting apache2 ...
 * start-stop-daemon: /usr/sbin/apache2 is already running                                                                                              [ ok ]
Comment 19 Stef Simoens 2012-05-24 20:35:22 UTC
Have the same problem here, with www-servers/apache-2.2.22-r1


hostname ~ # /etc/init.d/apache2 restart
 * Caching service dependencies ...                                                                                                                                                     [ ok ]
 * Stopping apache2 ...                                                                                                                                                                 [ ok ]
 * Starting apache2 ...
 * start-stop-daemon: /usr/sbin/apache2 is already running                                                                                                                              [ ok ]

=> after the "restart" the server isn't running
Comment 20 Duong H. Nguyen 2012-06-12 19:51:10 UTC
I confirm (In reply to comment #19)
> Have the same problem here, with www-servers/apache-2.2.22-r1
> 
> 
> hostname ~ # /etc/init.d/apache2 restart
>  * Caching service dependencies ...                                         
> [ ok ]
>  * Stopping apache2 ...                                                     
> [ ok ]
>  * Starting apache2 ...
>  * start-stop-daemon: /usr/sbin/apache2 is already running                  
> [ ok ]
> 
> => after the "restart" the server isn't running

I'm running the same version apache-2.2.22-r1 on x86-64.  I have tried to unmerge apache, apr, apr-util (following Gentoo Apache Troubleshooting Guide[1]), purge all of the configuration files and remerge them again but nothing changed.  Even worse, there is process Apache running on the background, using ~100% CPU, with no PID in /var/run/, and not responding to `apache2ctl describe fullstatus`.

[1] http://www.gentoo.org/proj/en/apache/doc/troubleshooting.xml
Comment 21 Ionut Turturica 2012-06-12 23:21:21 UTC
Did you run:
# dispatch-conf
Comment 22 Duong H. Nguyen 2012-06-13 07:58:50 UTC
(In reply to comment #21)
> Did you run:
> # dispatch-conf

I used `cfg-update -u` instead.

Anyway, althought I don't understand entirely, I discovered the cause of my problem.  Whenever I started Apache, I always received the warning:

    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

I tried adding `ServerName localhost` to httpd.conf, the warning was no longer there and Apache CPU usage dramatically dropped to normal.  However, still no response with `curl localhost`.

Tracking Apache error log gave me the following error:

    /usr/sbin/apache2: symbol lookup error: /lib64/libnss_compat.so.2: undefined symbol: sysconf, version GLIBC_2.2.5

Which made me remember that I recently switched to Gold from GNU Linker and updated the system several times, recompiling Apache one.  After rebuilding gcc, glibc, apr, apr-util, apache, php and some mod depend on them, now it works again.

My apologies for the false alarm and irrelevant comments.
Comment 23 Tony Vroon (RETIRED) gentoo-dev 2013-02-28 21:16:23 UTC
This bug has turned into a user support forum. If 2.2.23 or newer fails, please open a new bug and ensure you are not using the gold linker or other experimental gadgetry.