Scott Boms

Launching svnserve At Startup

Following up on this earlier post on getting started with Subversion, this time I want to look at getting the Subversion server running automatically when you start Mac OS X.

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!

So say you…

Thank you for this. I got it running.

But I am always curious how to set up a svn ( subversion ) with two or more projects using a separated machine as a server. Still after reading the svn docs I can’t figure this out.

Is it possible that you write an article about that?

Sunisa Chen Sunisa Chen March 5, 2007

I noticed that one of the parameters in your plist is “—daemon”. When reading the man page for launchd.plist (5), I noted this:

A daemon or agent launched by launchd MUST NOT do the following in the process directly launched by launchd:

* fork(2) and have the parent process exit(3) or _exit(2).
* Call daemon(3)

If I understand the above correctly, it applies to the —daemon parameter and should not be used. Have you tried it that way?

Aaron Burghardt Aaron Burghardt March 5, 2007

A good starting point for svn client-server issues is http://www.bsodmike.com/pages/svn-on-os-x/

Mike Mike March 5, 2007

If you want to run svnsurv on demand, you may want to look at the plist I made a while back: http://marc.baffl.co.uk/stuff.php#svnserv-plist

I prefer running svnserv on demand since my server is also a workstation. Hope it is useful.

Marc Marc March 5, 2007

@Marc - Thanks for the link. I’ll take a look at your version of the launchd plist.

@Aaron - No, haven’t tried leaving out the —daemon parameter.

Scott Scott March 7, 2007