Click here to Skip to main content
13,296,374 members (53,488 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 29 Aug 2006

Subversion Multiple Repository on a Single Server

, 29 Aug 2006
Rate this:
Please Sign up or sign in to vote.
This article shows how to run multiple Subversion instances inside a Windows Service, and within the same executable host a standard Windows Form application and provide an ASP.NET page to redirect your users to the specific repository.

Sample Image - subversioncodeprojectheader.gif


After reviewing the service wrapper for Subversion that is available at, I found that for the environment that I work in, we need to run multiple instances of the service, but I wanted to make it one service that is installed onto our server. Given that the Subversion server uses a very small (at least mine are) memory footprint, I came up with the idea of having the one service run multiple instances of the SVN server.

I also wanted the project to be able to be run purely as an Exe for the purposes of testing. We actually employ a strategy similar to this for another project so that our developers can run the program on their machine (without the requirement for the service installation), enabling the debugging of assemblies easier.... but that is another article :-)

Points of Interest

Given that it has been identified in the comments that this could be done easier using the Directory approach, hopefully someone will find it useful for the ability to host a Service and a regular WinForms application in one executable.

Setting up the Project

To create this project, you just use VS.NET to create a Windows Service application. This will create the necessary project files etc. You now will need to make some modifications to the sub Main to allow the application to run as a Service or as an application.

Setting the Service

To make the program be able to run in the correct mode, we will need to modify ServiceInstaller.vb so that when the service is installed, it will modify the command line parameters that are sent to the application.

We make our Main function in the service examine the command line to determine that these parameters have been supplied.

If Environment.GetCommandLineArgs.GetUpperBound(0) > 0 Then
  theArgs = theArgs.Substring(theArgs.IndexOf("/"))
  Dim collectionArgs() As String
  collectionArgs = theArgs.Split("/"c)
  Dim i As Integer
  For i = 1 To collectionArgs.GetUpperBound(0)
    Dim strParameterValue() As String
    strParameterValue = collectionArgs(i).Split("="c)
    Select Case strParameterValue(0).ToLower
      Case "mode"
        If strParameterValue(1).ToLower = "service" Then
          blnService = True
        End If
      Case Else

    End Select
  Next i
  blnService = False
End If

Now that we have run, we need to start the service, or run the application.

If blnService Then
  Dim ServicesToRun() As System.ServiceProcess.ServiceBase
  ServicesToRun = New System.ServiceProcess.ServiceBase() _
                      {New ServiceController(configFile)}
  ' Check for previous instance of the service or application
  If Diagnostics.Process.GetProcessesByName(_
       Diagnostics.Process.GetCurrentProcess.ProcessName).Length <= 1 Then
    Dim systemOperation As Start     
    systemOperation = New Start(configFile)
    System.Windows.Forms.Application.Run(New _
  End If 
End If

To see the intimate details of this, examine the source code in the "ServiceController.vb" and "Start.vb" files.

Setting up the Application

We use a ListView control presenting the information about the processes that we have created and the ports that we have running.

Setting up the ASP.NET page

The page is very simply a web based version of the application except that it enables you to click a link if you have TortiseSVN installed, and it will redirect you to that location.

Why am I looking at Subversion

I have been using SourceSafe for most of the development projects I have been involved with since I started working on the Windows platform around 10 years ago. After listening to Hanselminutes, I have been hearing and reading nothing but good things about Subversion. I also recently examined our SourceSafe to find that it had corrupted itself (fortunately, only a couple of files). Therefore, I have started showing our other developers the pros of Subversion with little to none of the cons associated with SourceSafe.

The speed at which check-in and out (Add, Update, Commit) are done is just outstanding.

Where to From Here

I will be revising the program to enable commands to be sent to the Service to perform a backup (and compress the backup), and also stop/start/restart a specific instance of the Subversion repository that is being run.

Bugs? What Bugs?

In the testing I have done, I haven't found any, but if you do, please let me know. I have tested this in Win2000, WinXP, and Win2003.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Paul Farry
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Member 463769721-Jul-13 21:10
memberMember 463769721-Jul-13 21:10 
GeneralEasier solution Pin
Jochen Jonckheere29-Aug-06 5:14
memberJochen Jonckheere29-Aug-06 5:14 
GeneralRe: Easier solution Pin
cadi29-Aug-06 5:32
membercadi29-Aug-06 5:32 
AnswerRe: Easier solution Pin
Jochen Jonckheere29-Aug-06 5:52
memberJochen Jonckheere29-Aug-06 5:52 
GeneralRe: Easier solution Pin
cadi29-Aug-06 6:58
membercadi29-Aug-06 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 29 Aug 2006
Article Copyright 2006 by Paul Farry
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid