Click here to Skip to main content
Click here to Skip to main content

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

Introduction

After reviewing the service wrapper for Subversion that is available at http://svnservice.tigris.org/, 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 Smile | :)

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
Else
  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)}
  System.ServiceProcess.ServiceBase.Run(ServicesToRun) 
Else   
  ' 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)
    systemOperation.Daemons.Start()
    System.Windows.Forms.Application.Run(New _
           ActiveRepositoriesForm(systemOperation.Daemons))
    systemOperation.Daemons.Stop()   
  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.

License

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

Share

About the Author

Paul Farry
Architect
Australia Australia
I've worked on Networking applications, Point of Sale systems, Distributed Server Controllers, and multiple Plugin Architectures for various Services that I've built for the companies I've worked for over the years.
 
I'm currently working for a Software Development company building the Installation system for a large scale corporate packages with hundreds of disparate models that are deployed to Cloud server instances.

Comments and Discussions

 
GeneralMy vote of 5 PinmemberMember 463769721-Jul-13 20:10 
GeneralEasier solution PinmemberJochen Jonckheere29-Aug-06 4:14 
I had the same problem, but I found an easier solution.
 
Place all the repositories in a folder or on a separate disk.
 
C:\Repos
└ Repository1
└ Repository2
└ Repository3

 
Install svnservice but point it to the global folder instead of one repository.
 
SVNService -install -d -r c:\repos
 
With your client you can connect to all 3 of them. (svn://servername/repository1)
 
Jochen
GeneralRe: Easier solution Pinmembercadi29-Aug-06 4:32 
AnswerRe: Easier solution PinmemberJochen Jonckheere29-Aug-06 4:52 
GeneralRe: Easier solution Pinmembercadi29-Aug-06 5:58 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 29 Aug 2006
Article Copyright 2006 by Paul Farry
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid