tags:

views:

153

answers:

1

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:

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

#!/bin/sh
# 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?

A: 

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.
Stefan Lasiewski