You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by silviu andrica <si...@gmail.com> on 2012/03/22 19:19:52 UTC

[users@httpd] Why is apache running after doing apachectl -k stop

Hello,

I was wondering if running the following commands
sudo /usr/local/apache2.3/bin/apachectl stop
echo $?
echo "should've stopped"
ps aux | grep apache | grep -v grep
sudo /usr/local/apache2.3/bin/apachectl start
echo $?
echo "should've started"
ps axu | grep apache | grep -v grep

should output something like this
0
should've stopped
root     22978  0.0  0.1 287964 30408 ?        Ss   18:39   0:00
/usr/local/apache2.3/bin/httpd -k start
www-data 23019  0.0  0.1 501196 26920 ?        S    18:39   0:00
/usr/local/apache2.3/bin/httpd -k start
www-data 23068  0.0  0.1 501196 26924 ?        S    18:39   0:00
/usr/local/apache2.3/bin/httpd -k start
httpd (pid 22978) already running
0
should've started
root     22978  0.0  0.1 287964 30408 ?        Ss   18:39   0:00
/usr/local/apache2.3/bin/httpd -k start
www-data 23019  0.0  0.1 501196 26920 ?        S    18:39   0:00
/usr/local/apache2.3/bin/httpd -k start
www-data 23068  0.0  0.1 501196 26924 ?        S    18:39   0:00
/usr/local/apache2.3/bin/httpd -k start

Moreover, doing ps aux | grep apache | grep -v grep after about a minute
yields no result. But sometimes, it does show an apache instance running.
To me, it seems like the stop command and start one are processed in
different orders.

My server configuration is the following:
Apache/2.3.4 (Unix) mod_ssl/2.3.4 OpenSSL/1.0.0e DAV/2 PHP/5.3.10
Server loaded APR Version: 1.4.0-dev
Module Magic Number: 20091119:1
MPM Name: worker
Server Architecture: 64-bit
Server Built With:
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/usr/local/apache2.3"
 -D SUEXEC_BIN="/usr/local/apache2.3/bin/suexec"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Best regards,
Silviu

Re: [users@httpd] Why is apache running after doing apachectl -k stop

Posted by Silviu Andrica <si...@gmail.com>.
Thanks for the replies.

I had the impression that apachetcl -k stop will not return until httpd stopped.

Cheers,
Silviu
On Mar 22, 2012, at 23:45 , Daniel Ruggeri wrote:

> On 3/22/2012 4:58 PM, Igor Cicimov wrote:
>> Thats too fast not all threads can close in just miliseconds you know.
>> Add "sleep 5" between stop and start and you should be fine.
> 
> The only concern with waiting for 5 seconds is that it might not be
> enough if a request is still finishing up.
> 
> I often have the same problem. I implement this inside my apachectl
> scripts after sending a shutdown signal:
> while [ -f $PIDFILE];do echo sleep;sleep 1;done
> 
> It keeps the script spinning until httpd removes the pidfile and also
> lets you know how many times it sleeps. This is particularly useful when
> scripting startup/shutdowns.
> 
> -- 
> Daniel Ruggeri
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Why is apache running after doing apachectl -k stop

Posted by Igor Cicimov <ic...@gmail.com>.
Yep, it's up to you how you are going to implement your script. The point
is you can't start the server until you confirm that all the
threads/children processes have died and the port 80 (or what ever port
your apache is running on) is free for the new process to bind to.


On Fri, Mar 23, 2012 at 9:45 AM, Daniel Ruggeri <DR...@primary.net>wrote:

> On 3/22/2012 4:58 PM, Igor Cicimov wrote:
> > Thats too fast not all threads can close in just miliseconds you know.
> > Add "sleep 5" between stop and start and you should be fine.
>
> The only concern with waiting for 5 seconds is that it might not be
> enough if a request is still finishing up.
>
> I often have the same problem. I implement this inside my apachectl
> scripts after sending a shutdown signal:
> while [ -f $PIDFILE];do echo sleep;sleep 1;done
>
> It keeps the script spinning until httpd removes the pidfile and also
> lets you know how many times it sleeps. This is particularly useful when
> scripting startup/shutdowns.
>
> --
> Daniel Ruggeri
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Why is apache running after doing apachectl -k stop

Posted by Daniel Ruggeri <DR...@primary.net>.
On 3/22/2012 4:58 PM, Igor Cicimov wrote:
> Thats too fast not all threads can close in just miliseconds you know.
> Add "sleep 5" between stop and start and you should be fine.

The only concern with waiting for 5 seconds is that it might not be
enough if a request is still finishing up.

I often have the same problem. I implement this inside my apachectl
scripts after sending a shutdown signal:
while [ -f $PIDFILE];do echo sleep;sleep 1;done

It keeps the script spinning until httpd removes the pidfile and also
lets you know how many times it sleeps. This is particularly useful when
scripting startup/shutdowns.

-- 
Daniel Ruggeri


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Why is apache running after doing apachectl -k stop

Posted by Igor Cicimov <ic...@gmail.com>.
Thats too fast not all threads can close in just miliseconds you know. Add
"sleep 5" between stop and start and you should be fine.
 On Mar 23, 2012 5:20 AM, "silviu andrica" <si...@gmail.com> wrote:

> Hello,
>
> I was wondering if running the following commands
> sudo /usr/local/apache2.3/bin/apachectl stop
> echo $?
> echo "should've stopped"
> ps aux | grep apache | grep -v grep
> sudo /usr/local/apache2.3/bin/apachectl start
> echo $?
> echo "should've started"
> ps axu | grep apache | grep -v grep
>
> should output something like this
> 0
> should've stopped
> root     22978  0.0  0.1 287964 30408 ?        Ss   18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
> www-data 23019  0.0  0.1 501196 26920 ?        S    18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
> www-data 23068  0.0  0.1 501196 26924 ?        S    18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
> httpd (pid 22978) already running
> 0
> should've started
> root     22978  0.0  0.1 287964 30408 ?        Ss   18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
> www-data 23019  0.0  0.1 501196 26920 ?        S    18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
> www-data 23068  0.0  0.1 501196 26924 ?        S    18:39   0:00
> /usr/local/apache2.3/bin/httpd -k start
>
> Moreover, doing ps aux | grep apache | grep -v grep after about a minute
> yields no result. But sometimes, it does show an apache instance running.
> To me, it seems like the stop command and start one are processed in
> different orders.
>
> My server configuration is the following:
> Apache/2.3.4 (Unix) mod_ssl/2.3.4 OpenSSL/1.0.0e DAV/2 PHP/5.3.10
> Server loaded APR Version: 1.4.0-dev
> Module Magic Number: 20091119:1
> MPM Name: worker
> Server Architecture: 64-bit
> Server Built With:
>  -D APR_HAS_SENDFILE
>  -D APR_HAS_MMAP
>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
>  -D APR_USE_SYSVSEM_SERIALIZE
>  -D APR_HAS_OTHER_CHILD
>  -D AP_HAVE_RELIABLE_PIPED_LOGS
>  -D HTTPD_ROOT="/usr/local/apache2.3"
>  -D SUEXEC_BIN="/usr/local/apache2.3/bin/suexec"
>  -D DEFAULT_ERRORLOG="logs/error_log"
>  -D AP_TYPES_CONFIG_FILE="conf/mime.types"
>  -D SERVER_CONFIG_FILE="conf/httpd.conf"
>
> Best regards,
> Silviu
>
>