Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have installed Subversion onto my iMac running Snow Leopard, but am having trouble getting svnserve to start up automatically. As I understand it (I'm still fairly green with OSX), the best way to do that is to utilize launchd. To that end, I have created the following .plist file in the /Library/LaunchDaemons folder. If I use launchctl to execute this file, svnserve starts as expected, but it doesn't automatically start when the system starts up or I log in.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>org.tigris.subversion.svnserve</string>
<key>UserName</key>
<string>Dave</string>
<key>ProgramArguments</key>
<array>
    <string>/opt/subversion/bin/svnserve</string>
    <string>--inetd</string>
    <string>--root=/Users/Shared/SVNrep</string>
</array>
<key>ServiceDescription</key>
<string>Subversion Standalone Server</string>
<key>Sockets</key>
<dict>
    <key>Listeners</key>
    <array>
        <dict>
            <key>SockFamily</key>
            <string>IPv4</string>
            <key>SockServiceName</key>
            <string>svn</string>
            <key>SockType</key>
            <string>stream</string>
        </dict>
        <dict>
            <key>SockFamily</key>
            <string>IPv6</string>
            <key>SockServiceName</key>
            <string>svn</string>
            <key>SockType</key>
            <string>stream</string>
        </dict>
    </array>
</dict>
<key>inetdCompatibility</key>
<dict>
    <key>Wait</key>
    <false/>
</dict>
</dict>
</plist>

If anyone here could provide any suggestions as to how to get this to work, I'd really appreciate it.

share|improve this question
    
There is usually something you have to do to add the "service" to a "runlevel". I'm not sure what the terms are for MacOS. –  d-_-b Jun 4 '10 at 0:04
    
@sims like on BSD systems, Mac OS X doesn't have runlevels –  radius Jun 4 '10 at 5:54
    
Maybe all BSDs do not have runlevels, but from what I remember, they do have some kind of init sequence and single and multi user "modes". You can enable what services you would like started by editing rc.conf. There are startup scripts in rc.d. Of course, MacOS may not have any of that, which is why this is just a comment. –  d-_-b Jun 6 '10 at 7:17
add comment

3 Answers 3

Try to add this key

<key>RunAtLoad</key>
<true/>

(at the same 'level' than Disabled, Label, ... keys

share|improve this answer
    
I tried that, but it didn't work. I then removed it and added the OnDemand key, but that made no difference either. In both cases, I rebooted the machine after each config change. –  Cleggy Jun 4 '10 at 7:25
    
Try to change Listeners section with a simplier config like listing 3 on developer.apple.com/macosx/launchd.html or try a non inetd setup. –  radius Jun 4 '10 at 10:56
    
When I use the simpler Listeners section from section 3, I get 'bind() : Permission denied' when attempting to load the .plist file using launchctl. I'm not sure what you mean by 'try a non inetd setup'. Can you please give an example? All I am trying to achieve is have my SVN repository available to multiple machines on my LAN. If there is a simpler way to achieve this that you know of, feel free to share. –  Cleggy Jun 4 '10 at 23:00
    
You use --inetd option, so you must have a Listeners, this makes the configuration more complicated, try without that. Take a look the plist that you can download here: scottboms.com/2007/03/launchsvnserveatstartup this lanunch svnserve as a deamon. –  radius Jun 6 '10 at 17:36
    
That plist file has the same symptom. It works if I use launchctl load, but doesn't restart svnserve on reboot (and launchctl list shows no sign of the .plist) –  Cleggy Jun 6 '10 at 23:00
add comment

I've not created any launchd plists in inetdCompatibility mode, but I've found running programs in daemon mode w/KeepAlive's NetworkState set to true to work pretty well. You have to use NetworkState when running in daemon mode as launchd doesn't do dependancies at all, so the daemon almost always gets started before the network is up.

So, I'd probably try a /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist that looked like this:

<?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">
        <dict>
                <key>Label</key>
                <string>org.tigris.subversion.svnserve</string>
                <key>ProgramArguments</key>
                <array>
                        <string>/opt/subversion/bin/svnserve</string>
                        <string>-d</string>
                        <string>--root=/Users/Shared/SVNrep</string>
                </array>
                <key>RunAtLoad</key>
                <true/>
                <key>KeepAlive</key>
                <dict>
                    <key>NetworkState</key>
            <true/>
                </dict>
        </dict>
</plist>
share|improve this answer
add comment

A couple of options that I found.

First, http://www.kashum.com/blog/1217783696 describes using the plist method, but it appears to specify more options in the xml than you're using.

Second, http://www.scottboms.com/2007/03/launchsvnserveatstartup/ describes using an prebuilt working plist file to drop into the LaunchDaemons folder, modify the path specified, and then run

sudo launchctl load /Library/LaunchDaemons/org.tigris.Subversion.plist

and verify that it's working with

sudo launchctl list

(or, y'know, trying to use svn...)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.