In the earlier post we ran the
svnserve daemon manually. While this is fine as a one-off event, if you ever need to restart your system, we shouldn’t have to worry about remembering to start the process manually. Instead you’ll want to automate it. Thanks to the powerful launch facilities built into Mac OS X, this is a simple process and I’ll make it even easier for you.
The preferred way of launching background processes in Mac OS X means using
launchd by creating LaunchDaemons and LaunchAgents which are simple plist (Property List) files which instruct launchd on how to start or stop these processes. The important difference in the two is that LaunchDaemons are intended for processes which should remain running even with no users logged into the system; perfect for Subversion.
Download this LaunchDaemon plist file and copy it to the LaunchDaemons folder in the Library folder on your system. Open the file in your preferred text editor and look at line 16. If you followed the earlier post on setting up Subversion, then you don’t need to do anything. If you created your repository in another location, you’ll need to edit the path to the repository on that line. When you’re done, save the file.
We’re now ready to make sure it will work. If you’ve got the
svnserve daemon running, open up the Activity Monitor and locate the
svnserve process. Select it and press the Quit Process button in the Activity Monitor toolbar. You should be asked for your administrator password. When the process exits it will disappear from the list.
After the process has closed, switch back to the Terminal. We’re ready to test our LaunchDaemon to start it up again. In the Terminal, type the following:
sudo launchctl load /Library/LaunchDaemons/org.tigris.Subversion.plist
Enter your administrator password. You should be returned to a new prompt in the shell if everything goes well.
To verify that our process is registered with launchd, we can print out a list of all the processes run with
launchctl by running:
sudo launchctl list
You should see the
org.tigris.Subversion item in the list. You can further test that the LaunchDaemon works by simply restarting your system and again checking the Activity Monitor to verify that the
svnserve process is running.
Happy version control!