0 subscribers Search:
last edited 6 years ago by Will

A.8. Automatic Startup and Shutdown Using Daemontools

D.J. Bernstein's Daemontools provide another method of controlling Jabberd 2 through machine startup and shutdown. This appendix assumes that Daemontools are installed on your system. See How to Install Daemontools for installation instructions. See the Daemontools homepage for a description of Daemontools.

Daemontools configuration requires a run script in a dedicated directory. This directory is then symbolically linked to the /service directory for monitoring by the Svscan daemon of Daemontools. This how-to is a bit long because each of the Jabberd 2 binaries must have its own linked directory and run script. Additionally, the PID file writing should be disabled (in Jabberd XML configuration) for each of the binaries.

A.8.1. Create Master Directory

Create a master directory for the 5 Daemontools directories to be created below. The most convenient place for this directory is in /usr/local/etc/jabberd/. Create this new directory (as root):

      mkdir /usr/local/etc/jabberd/daemontools

A.8.2. Create Run Directories for Binaries

Create a sub-directory for each of the Jabberd binaries:

      mkdir /usr/local/etc/jabberd/daemontools/router

      mkdir /usr/local/etc/jabberd/daemontools/resolver

      mkdir /usr/local/etc/jabberd/daemontools/sm

      mkdir /usr/local/etc/jabberd/daemontools/c2s

      mkdir /usr/local/etc/jabberd/daemontools/s2s

You should now have 5 sub-directories under /usr/local/etc/jabberd/daemontools/.

A.8.3. Create Run Scripts

Each of the sub-directories now needs a run script for its respective Jabberd binary. Change to the router sub-directory to create your first run script:

      cd /usr/local/etc/jabberd/daemontools/router

Using an editor, create a file called run in this directory. Edit the file as below so that it contains a run script for the router component:

      #!/bin/sh
      exec setuidgid jabber /usr/local/bin/router /usr/local/etc/jabberd/router.xml

Repeat this process for each of the remaining 4 sub-directories. You can use the above text as a template, and replace the 2 instances of router with the respective Jabberd binary (resolver, sm, c2s and s2s). For example, the run file in the resolver sub-directory should be created as below:

      #!/bin/sh
      exec setuidgid jabber /usr/local/bin/resolver /usr/local/etc/jabberd/resolver.xml

A.8.4. Make Run Scripts Executable

Each of the run scripts above needs to be executable. Run the command below to make each of the run scripts executable:

      chmod 0755 /usr/local/etc/jabberd/daemontools/*/run

A.8.5. Disable PID's for each of the Jabberd Binaries

Svscan does not rely on PID files; therefore, PID file writing should be disabled in each of these configuration files:

      router.xml
      resolver.xml
      sm.xml
      c2s.xml
      s2s.xml

Near the top of each of these files is a tag set for the PID file location. Comment these tags in each file above to disable PID file writing. For example, the top of router.xml should appear as below:

      <!-- Router configuration -->
      <router>
        <!-- ID of the router on the network (default: router) -->
        <id>router</id>

        <!-- The process ID file. comment this out if you don't need to know
             to know the process ID from outside the process (eg for control
             scripts) -->
        <!-- <pidfile>/usr/local/var/jabberd/pid/router.pid</pidfile> -->    

A.8.6. Create Symbolic Links

Each of the sub-directories now needs to be linked to the /service/ directory. Once these symlinks are created, svscan will start and monitor the respective process.

I Important: Stop Jabberd Server Before Proceeding
In order to prevent conflicts, you should make certain that your Jabberd server is completely stopped before proceeding with the final step of Daemontools configuration.

Create 5 symlinks as below:

      ln -s /usr/local/etc/jabberd/daemontools/router /service

      ln -s /usr/local/etc/jabberd/daemontools/resolver /service

      ln -s /usr/local/etc/jabberd/daemontools/sm /service 

      ln -s /usr/local/etc/jabberd/daemontools/c2s /service

      ln -s /usr/local/etc/jabberd/daemontools/s2s /service

A.8.7. Check that Services are Running

Make sure that the svscan daemon is running on your machine. On my distro (Gentoo Linux), the svscan daemon is started from /etc/init.d. You should now be able to check the status of your Jabberd services by using the svstat command. For example, to check the status of the router component, you would switch to the /service directory and then enter the svstat command as below:

      svstat router

You should see output similar to this:

      router: up (pid 20011) 248 seconds

Svscan will now monitor your Jabberd processes, and if a process goes down, Svscan will restart it.

N Note: Svscan Should Be Set to Start at Boot
If you just installed Daemontools, you may need to add the svscan daemon to an appropriate run level so that it starts during boot. Consult your distro's documentation for the best way to do this.

View as PDF

Up

Comments about this Document


full simple minimal   UserOptions ChangeLog   loginhelp

© 2003 Will Kamishlian and Robert Norris

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Powered by Zope Valid HTML 4.01! Valid CSS! Creative Commons License