Mon Apr 30 18:25:00 UTC 2007
Running svnserve as a Windows Service
It took me a while to assemble this information about what needs to be done to run svnserve as a Windows service and since I shall need this information in another few days when I set it up on a different server, it made sense to link it here.
Background
svnserve allows you to connect remotely to an SVN repository over a network. In these cases, the repository names are something like “svn://server/project” and this is regarded as one of the easiest ways to connect over a network. This method is usually recommended for corporate LANs where you are confident that your communication is safe from snooping. There are other ways such as ssh + svn which can offer greater security, but I digress.
If you decide that svnserve will work for you and you have svn running on a Windows computer, then you may want to run it as a service. That way, it can be made to start up automatically when the computer restarts (as it will every now and then if it has just installed a bunch of updates automatically) and is generally easier to manage.
What needs to be done?
Basically, the latest svnserve already has everything that is needed to run it as a service. All you need to do is install it as service by passing it the correct options. Let’s assume that you have the following settings:- Subversion Installation:
C:\DevSupport\Subversion - Repository:
D:\Repository
If this is the case, you need to go to a Command Window (Start Key> Run> cmd [enter] >) and run the command SC.exe to interact with the service manager. You could type sc.exe to see how it works and what it expects from you.
For the impatient, this is what you need to type in at the command prompt to register svnserve as a service.
C:\>sc create svn_repos binpath= "C:\DevSupport\Subversion\bin\svnserve.exe --service --root D:\Repository" displayname= "Subversion Repository" depend= Tcpip
There a few things to note here:
- Options to
sc createmust have the equal-to sign stuck to the option name (it’s part of the option name) and there must be one space after it. So,depend= Tcpipis correct anddepend = Tcpip,depend=Tcpipanddepend =Tcpipare all wrong. - The display name is what it will show up as in the Service Manager. You can set it to whatever you like.
- The binpath is the actual command line that will be called. Note that the option to run it as a service is
--serviceand no other option works. It must be--serviceif it is to work.
Do I need one service for each repository?
In short, No. The command line option to svnserve only identifies a root directory which will be served up. The repository can be in any directory below it.
Suppose that your repository looks something like this:
D:\Repository | |- Project 1 | |- Project 2 | |- Project 3
and you use the above to serve it up, then the URLs for accessing the 3 projects from a Subversion client will be:
Project1 - svn://server/Project1 Project2 - svn://server/Project2 Project3 - svn://server/Project3
So, basically, if the individual project repositories are under the same root directory, you do not need a separate service. You will need a separate service for each root directory because I don’t think that a single svnserve service can handle multiple root directories.
How do I make it automatically start upon reboot?
The steps above will only ensure that the service is installed. If you want the service to start, you need to do a couple of other things.
- Go to the Service Manager (Start Button> Run> services.msc [enter])
- Find the service you just installed (if you called it Subversion Repository, then that will be the service name)
- Right-click on the name of the service and select properties.
- If the service is not running, start it by clicking on ‘Start’
- Change the start-up type to ‘Automatic’
- Click on ‘Apply’ or ‘OK’ and exit the page.
The service is now running and will be automatically started every time Windows is restarted.
Refer to this note for all the gory details.
Sorry, comments are closed for this article.