Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Hoping that somebody can help us understand this behavior.

We've got a bunch of daemontools services under /etc/service/. One of the services controls apache, and the run script has this in it.

exec envdir /var/lib/supervise/wwwproxy/env setuidgid root bash <<-BASH
    ulimit -n 8192  # also increase the running user's file descriptor limit
    exec apache2 -f /path/to/demo_apache2.conf -D FOREGROUND
BASH 

We were having the problem that svc -d /etc/service/* actually had the effect of restarting all the services, it didn't take them down. We finally tracked it down to that one service, and found that svc -d /etc/service/apache2 would bring up any other service was down, including itself.

Changing FOREGROUND to NO_DAEMONIZE fixes the behavior, but we'd really like to understand what's going on. Can anybody explain why an svc -d on one service would bring an other service up?

Thanks for any clue you can offer.

share|improve this question
1  
Why aren't you just using an initd script? –  jamieb Aug 15 '12 at 0:49
1  
---Can you post the run script you're using for Apache?--- <-Nevermind, I'm blind :-) Also, can you tell us why in the name of everything unholy you're using supervise to control Apache? (Apache does its own process management, and it does a good job of it. You're almost certainly better off with a watchdog script than trying to hack together a solution with daemontools...) –  voretaq7 Aug 15 '12 at 1:31

2 Answers 2

For me -D NO_DAEMONIZE didn't work, I had to use -D NO_DETACH. (CentOS 6.3, Apache/2.2.15)

See also http://httpd.apache.org/docs/2.2/programs/httpd.html:

Also can be used to set certain less-common startup parameters including -DNO_DETACH (prevent the parent from forking) and -DFOREGROUND (prevent the parent from calling setsid() et al).

share|improve this answer

My suggestion would be to not use daemontools to run Apache, but in lieu of that you should simplify your run script.

Start with the barest of minimums:

#!/bin/bash
exec apache2 -f /path/to/httpd.conf -D NO_DAEMONIZE

If you need/want to use envdir you can start apache with that instead of exec.
The ulimit call is probably not necessary, but can be added anywhere in the run script before you launch Apache.


Re: the actual strange behavior you're seeing, there are some functional differences between -DFOREGROUND and -DNO_DAEMONIZE -- the latter is what I've always seen recommended for running Apache under daemontools (preceded by the obligtory "Don't Do That") -- I don't know why any of those differences would cause the behavior you describe though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.