I am trying to setup daemontools for two apaches in one server. one apache 2.2 listening on port 80 proxy request to a second apache 1.3 listening on port 8888. ./run script as following:

# apache 1.3
exec /apache_1_3/apache/bin/httpd -F

# apache 2.2
exec /apache_2_2/apache/bin/httpd -D FOREGROUND

daemontools monitors both apache fine. however, If I stop apache2.2 (using svc -t or apachectl), the apache 1.3 will see the following error in error_log

[crit] (98)Address already in use: make_sock: could not bind to port 8888

I had to manually apachectl stop the apache1.3 to stop the error message clobber the log file.

There is no such problem before using daemontools.

any idea why this is happening?


You shouldn't define two daemons inside a single script. You are execing two daemons, but I believe Daemontools will only monitor the second exec'd daemon.

Here's what I believe is happening:

  • Your script spawns two process
    • Daemontools starts the first process and the second process, but it will only monitor the second process. The first process is ignored.
  • You kill the second process. The first process, Apache 1.3 is still running.
  • Daemontools notices that the second process is dead, and so it re-runs the run script.
  • Your script tries spawns two processes again.
    • The Apache 1.3 process fails to start again, because Apache is already running and listening on that port.
    • The apache2.2 process starts fine.
  • 1
    I know this question and answer are really old but I stumbled upon it with google so I wanted to correct it: when the exec line is executed the calling program is replaced with the new program from the arguments to exec. I suppose in the question there are two services defined otherwise only the first would be executed. – Schmurfy Sep 26 '11 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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