Kyle’s Reference Links

Contents External Links Friendly Links Marvin Links

daemontools on MacOS X

by Rob Mayoff

These steps will guide you through installing daemontools 0.76 on MacOS X 10.1.1. Steps that differ significantly from Dan Bernstein's installation instructions are in red if your browser supports CSS. Please send comments and corrections to mayoff-daemontools-macosx@dqd.com.

  1. Install the BSD Subsystem package from the MacOS X install CD, if you have not already done so.

  2. Open a Terminal window. The Terminal application is in the Utilities folder, which is in the Applications folder.

  3. Become root:

    sudo -s

    You will probably need to type in your password (not root's password) after running the sudo command.

  4. Create the /service directory:

    mkdir -p /service

    We do this now to prevent the daemontools installer from doing a step that does not work on MacOS X.

  5. Create the /package directory and change to it:
    mkdir -p /package
    chmod 1755 /package
    cd /package
  6. Download daemontools-0.76.tar.gz:
    curl -O http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
  7. Unpack the daemontools package:
    tar xpzf daemontools-0.76.tar.gz
    rm daemontools-0.76.tar.gz
  8. Set the compiler and linker commands:

    cd admin/daemontools-0.76/src
    perl -pi -e 's/^gcc/cc/' conf-*
    perl -pi -e 's/-s/-Wl,-x/' conf-ld

    After this step, conf-cc should contain this:

    cc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings
    
    This will be used to compile .c files.

    and conf-ld should contain this:

    cc -Wl,-x
    
    This will be used to link .o files into an executable.
  9. Compile and install daemontools:
    cd ..
    package/install

    Normally this step would create /service and append two lines to /etc/rc.local. However, MacOS X does not use /etc/rc.local. Since we already created /service, package/install will not try to create it or modify /etc/rc.local.

  10. Create a new subdirectory named /System/Library/StartupItems/ServiceScanner, and change to that directory:
    cd /System/Library/StartupItems
    mkdir ServiceScanner
    cd ServiceScanner
  11. Create a shell script named ServiceScanner to start svscan:
    cat > ServiceScanner <<end
    #!/bin/sh
    echo "Starting svscan"
    /command/svscanboot &
    end
    chmod +x ServiceScanner

    Be very careful to include the & at the end of the svscanboot line. If you leave that out, your system will hang while booting and you'll have to boot in single-user mode (by holding down Command-S during during the boot sequence) to fix it.

  12. Create a property list file named StartupParameters.plist describing the new startup item:
    cat > StartupParameters.plist <<end
    {
      Description = "daemontools svscan";
      Provides = ("svscan");
      OrderPreference = "None";
      Messages =
      {
        start = "Starting svscan";
      };
    }
    end
  13. Reboot.

You can check that svscan is running using the ps command. For example:

[ice:~] root# ps axwww | egrep 'svscan|readproctitle'
  245  ??  S      0:00.02 sh /command/svscanboot
  250  ??  S      0:00.15 svscan /service
  251  ??  S      0:00.02 readproctitle service errors: ................................................
  389 std  R+     0:00.00 egrep svscan|readproctitle
Valid XHTML 1.0 Strict! Valid CSS! Lovingly handcrafted with Vim