Edgewall Software

Launch tracd automatically with launchd

If you're running trac on a project for local access only, you can use tracd to serve it up, rather than Apache. Under Mac OS X Tiger, use launchd to make sure that tracd is launched and ready to use whenever you want it.

Here's a recipe.

  1. Create a launchd agent plist file.
  2. Copy the agent plist file to /Library/LaunchAgents or ~/Library/LaunchAgents.
  3. Use launchctl to load the plist and start tracd now.
  4. Browse your local trac project
  5. Profit!

1. Create a launchd agent plist file

You'll need to create a file with a description of the tracd service that launchd can use. Use the one below as a template. It is configured to run the tracd server on port 9000, and launch it automatically.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <string>my local tracd server</string>

To customize this agent description for your local tracd project, edit the array of strings under the key "ProgramArguments". What's happening here is that the shell command for starting the tracd server is split up such that its element parts are on separate lines.

If "/usr/local/bin/tracd -p 9000 /path/to/your-trac-project-env" is the shell command that would launch tracd from Terminal, you would configure the ProgramArguments key as follows:

The first <string> entry is the path to the tracd executable. /usr/local/bin/tracd is the default path; you should only have to change this if you've installed tracd somewhere on your system.

The third <string> entry is the port number argument.

The final <string> entry is the path to the trac environment directory for your project.

If you're using authentication for your tracd server, insert a new <string> entry before the final one to contain the —auth argument. E.g., assuming your htdigest file is named "users.htdigest", and, in creating the digest, you used "TracRealm" as the realm value,


Save this launchd configuration to a file named "localhost.trac.plist". Put it on the desktop for now. You'll copy it to a more appropriate location in the next step.


OnDemand <boolean>
     This key was used in Mac OS X 10.4 to control whether a job was kept alive or not. The default was
     true.  This key has been deprecated and replaced in Mac OS X 10.5 and later with the more powerful
     KeepAlive option.

So if you're running 10.5 and later, you should replace OnDemand by KeepAlive. Also notice that the meaning are opposite of each other: OnDemand True should be translated by KeepAlive False.

Tip: Once you're done with your changes, avoid wasting a lot of time due to ill formatted files, and validate your plist:

plutil -lint org.edgewall.trac.plist

2. Install the plist file in a LaunchAgents directory.

You'll need to copy the agent plist file to an appropriate LaunchAgents folder. Which folder you copy it to depends on when you want it be launched.

If you want tracd to be launched when your Mac starts up, use the /Library/LaunchAgents folder.

If you want tracd to be launched only when a particular user logs on to the Mac, use the ~/Library/LaunchAgents folder for that user account. If the LaunchAgents folder doesn't exist, you'll need to create it.

3. Use launchctl to start the tracd server now.

Once you're done with step 2, launchd will automatically start your tracd service, either on the next restart or the next login to the particular user account where the agent plist was installed.

To get tracd going right away, use the launchctl command. Open a Terminal window, and enter the commands below. These commands will change the working directory to the LaunchAgents folder, load the agent plist into launchctl's database, start the tracd service, and check the process list to see if the tracd process actually got started.

cd /Library/LaunchAgents
# If you installed the agent plist into ~/Library/LaunchAgents, cd there instead.
sudo launchctl load ./localhost.trac.plist
sudo launchctl start localhost.trac
ps -ax | grep tracd | grep -v grep

If the "ps -ax" command doesn't return anything, tracd didn't launch. Verify that you can get tracd to launch from a Terminal shell and make sure that the command configured under the ProgramArguments key matches what you used on the command line.

The freeware application Lingon, http://lingon.sourceforge.net/, provides a GUI for creating and editing launchd descriptions. I used Lingon to get a tracd service launching on my Mac, and derived the template plist file above from it. Lingon could be useful for debugging your plist file (it has a command at least for validating that the plist is formatted correctly).

4. Browse your local trac project

If tracd is running, you'll be able to browse the trac project at http://localhost:9000. A link to your project should be listed on the page that appears.

Last modified 10 years ago Last modified on Dec 10, 2011, 2:27:06 PM
Note: See TracWiki for help on using the wiki.