Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

The question of Apache deamontools

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


liujg at cn

Aug 8, 2012, 11:43 PM

Post #1 of 4 (236 views)
Permalink
The question of Apache deamontools

ApacheGroup Mem:

hello,boys~

I use the deamontools to control the apache.
run script as following(refer to the doc of www):
-------------------------------------
#!/bin/sh

CONF=/etc/httpd/conf/httpd.conf
DAEMON=/usr/sbin/httpd
DAEMON_ARGS="-f $CONF -DNO_DETACH -DFOREGROUND -d /etc/ahttpd -DHAVE_SSL"

exec 2>&1

exec pgrphack $DAEMON $DAEMON_ARGS
-------------------------------------

1.
exec 2>&1
This code redirect the stderr to stdout,
but what is the funcion of this code? why add it?(I find that the doc of
internet almost all of them add the code)
when delete it, what is happened?
2.
when use the deamontools to control the apache.
for example(process):
---------------------------
root 4418 4416 supervise ahttpd
|
root 20110 4418 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf
-DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
|
ipcom 20113 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf
-DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
ipcom 20114 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf
-DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
ipcom 20115 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf
-DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
ipcom 20116 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf
-DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
--------------------------
If I only kill the parent httpd (20110), apache cannot restart.
If I kill all the httpd (20110,20113 ...) , apache can restart.

The reason is?

Thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


nick at webthing

Aug 9, 2012, 3:11 AM

Post #2 of 4 (227 views)
Permalink
Re: The question of Apache deamontools [In reply to]

On 9 Aug 2012, at 07:43, Liu JinGang wrote:

> I use the deamontools to control the apache.

Why?

It's not a configuration we'd recommend: in fact it seems to be running
multiple instances in what would normally be a debugging mode.

If someone is indeed recommending it, perhaps you should put
your question to them?

--
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


brett.maxfield at gmail

Aug 9, 2012, 4:10 AM

Post #3 of 4 (227 views)
Permalink
Re: The question of Apache deamontools [In reply to]

On 09/08/2012, at 1:43 PM, Liu JinGang <liujg [at] cn> wrote:

> ApacheGroup Mem:
>
> hello,boys~
>
> I use the deamontools to control the apache.
> run script as following(refer to the doc of www):
> -------------------------------------
> #!/bin/sh
>
> CONF=/etc/httpd/conf/httpd.conf
> DAEMON=/usr/sbin/httpd
> DAEMON_ARGS="-f $CONF -DNO_DETACH -DFOREGROUND -d /etc/ahttpd -DHAVE_SSL"
>
> exec 2>&1
>
> exec pgrphack $DAEMON $DAEMON_ARGS
> -------------------------------------
>
> 1.
> exec 2>&1
> This code redirect the stderr to stdout,
> but what is the funcion of this code? why add it?(I find that the doc of internet almost all of them add the code)
> when delete it, what is happened?

The 2>&1 takes all output of stderr (file descriptor 2) and redirects it to stdout (file descriptor 1)

In the context of starting a daemon, if stdout is redirected like 1>/dev/null then stderr will do the same. It frees the relationship between the invoking shell and the daemon program. Otherwise the program might exit when you close the shell you used to launch the daemon.

You can redirect stdout to a file eg 1>debug.log, but this is only helpful for testing. In your example all output of stderr and stdout, will go to the invoking shell as httpd is running in foreground mode for debugging.

Most long running programs will write thier own logs, so you probably want to use these, as they can be easily rolled. A log file made with redirection, can grow very large, and cant be rolled without stopping the owning daemon first.

> 2.
> when use the deamontools to control the apache.
> for example(process):
> ---------------------------
> root 4418 4416 supervise ahttpd
> |
> root 20110 4418 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
> |
> ipcom 20113 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
> ipcom 20114 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
> ipcom 20115 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
> ipcom 20116 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
> --------------------------
> If I only kill the parent httpd (20110), apache cannot restart.
> If I kill all the httpd (20110,20113 ...) , apache can restart.
>
> The reason is?

You are running httpd in foreground mode, you dont usually do that unless you are debugging or testing something.

Out of interest, nearly every linux distribution comes with an init script for apache, why are you writing your own ?

All modern Apache's itself already has this functionality in the apachectl script ? Usually an init script would just call that for start/stop/restart etc., i'd look in an existing init script for an example..

Cheers
Brett

>
> Thanks!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


liujg at cn

Aug 10, 2012, 12:36 AM

Post #4 of 4 (219 views)
Permalink
Re: The question of Apache deamontools [In reply to]

Hi Rainer,

Thanks for your helps!


On 2012-08-09 20:10, Brett Maxfield wrote:
>
>
>
>
> On 09/08/2012, at 1:43 PM, Liu JinGang <liujg [at] cn> wrote:
>
>> ApacheGroup Mem:
>>
>> hello,boys~
>>
>> I use the deamontools to control the apache.
>> run script as following(refer to the doc of www):
>> -------------------------------------
>> #!/bin/sh
>>
>> CONF=/etc/httpd/conf/httpd.conf
>> DAEMON=/usr/sbin/httpd
>> DAEMON_ARGS="-f $CONF -DNO_DETACH -DFOREGROUND -d /etc/ahttpd -DHAVE_SSL"
>>
>> exec 2>&1
>>
>> exec pgrphack $DAEMON $DAEMON_ARGS
>> -------------------------------------
>>
>> 1.
>> exec 2>&1
>> This code redirect the stderr to stdout,
>> but what is the funcion of this code? why add it?(I find that the doc of internet almost all of them add the code)
>> when delete it, what is happened?
>
> The 2>&1 takes all output of stderr (file descriptor 2) and redirects it to stdout (file descriptor 1)
>
> In the context of starting a daemon, if stdout is redirected like 1>/dev/null then stderr will do the same. It frees the relationship between the invoking shell and the daemon program. Otherwise the program might exit when you close the shell you used to launch the daemon.
>
> You can redirect stdout to a file eg 1>debug.log, but this is only helpful for testing. In your example all output of stderr and stdout, will go to the invoking shell as httpd is running in foreground mode for debugging.
>
> Most long running programs will write thier own logs, so you probably want to use these, as they can be easily rolled. A log file made with redirection, can grow very large, and cant be rolled without stopping the owning daemon first.
>
>> 2.
>> when use the deamontools to control the apache.
>> for example(process):
>> ---------------------------
>> root 4418 4416 supervise ahttpd
>> |
>> root 20110 4418 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
>> |
>> ipcom 20113 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
>> ipcom 20114 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
>> ipcom 20115 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
>> ipcom 20116 20110 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -DNO_DETACH -DFOREGROUND -d /etc/httpd -DHAVE_SSL
>> --------------------------
>> If I only kill the parent httpd (20110), apache cannot restart.
>> If I kill all the httpd (20110,20113 ...) , apache can restart.
>>
>> The reason is?
>
> You are running httpd in foreground mode, you dont usually do that unless you are debugging or testing something.
>
> Out of interest, nearly every linux distribution comes with an init script for apache, why are you writing your own ?
>
> All modern Apache's itself already has this functionality in the apachectl script ? Usually an init script would just call that for start/stop/restart etc., i'd look in an existing init script for an example..
>
> Cheers
> Brett
>
>>
>> Thanks!
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe [at] httpd
>> For additional commands, e-mail: users-help [at] httpd
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.