Saturday, February 4, 2017

How to set up multiple Gitora installations on the same server

When you use Gitora on multiple databases (DEV, CI, TEST) you need to have multiple Gitora installations, one for each database.

There are a few things you need to change in Gitora if you want to have have multiple Gitora client (Tomcat) installations on the same machine.

First is the HTTP port. You can choose the port you want to run Gitora on during the Gitora installation, so that is no problem.

But notice the "Note: Port no 8005 and 8009 must not be used by a service or application".
So we need to change some ports afterwards to make it work.

Here is how to do that.
In this example we will set up 2 Gitora installations, DEV and TEST.

Install Gitora DEV 

DEV will run on port 8080 and will use all default ports, so we do not have to change anything after the Gitora installation wizard.

Tomcat server.xml

Ports 8005 and 8009 are defined in the server.xml file, with me the file is located at:
C:\Program Files (x86)\Gerger\GitoraServer-DEV\apache-tomcat-7.0.69\conf\server.xml

Also, the port 8080 is in here and one more, port 8443 (redirectPort)
<Server port="8005" shutdown="SHUTDOWN">
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

As we run the DEV instance with default, no need to change anything here now.


Another interesting port is the Git deamon port in the Gitblit file. With me the file is located at:
C:\Program Files (x86)\Gerger\GitoraServer-DEV\gitblit-config\
# port for serving the Git Daemon service.  <= 0 disables this service.
# On Unix/Linux systems, ports < 1024 require root permissions.
# Recommended value: 9418
# SINCE 1.3.0
git.daemonPort = 9418

# The port for serving the SSH service.  <= 0 disables this service.
# On Unix/Linux systems, ports < 1024 require root permissions.
# Recommended value: 29418
# SINCE 1.5.0
git.sshPort = 29418

Install Gitora TEST 

TEST will run on http port 8081 (you can specify it during install) and we will manually change the rest of the ports in the config files.
First stop Gitora DEV, otherwise the installer cannot continue when it detects ports 8005 an 8009 are in use.

change Tomcat server.xml

Open server.xml (see file location mentioned above) and change the ports, for example.
port 8005 to 8006
port 8009 to 8010
port 8443 to 8444

change Gitblit

Open Gitblit (see file location mentioned above)  and change the Git deamon port and SSH port.
daemonPort from 9418 to 9419
sshPort from 29418 to 29419

At this point you are able to run the 2 Gitora instances at the same time on the same machine without any port conflicts and all standard functions should work.

Remote pull from DEV to TEST

With the setup we did so far you are already able to remote pull from the DEV to the TEST repository.
This works by default, because the Git deamon port on DEV has not been changed.
The pull will look at the default port 9418 (for http connections).

Remote pull from TEST to DEV

But pulling from TEST to DEV will not work, because we changed the default Git deamon port on TEST from 9418 to 9419.

In order to pull from TEST to DEV we must change the Git deamon port in the remote repository definition in Gitora DEV to 9419 (the deamon port we configured in Gitora TEST setup).

Here is how to do that:

1. Create a remote repository in the Gitora DEV installation that looks at the TESTREPO, something like this:

(Note that the Port here is 8081, that is the http port of the Gitora TEST instance)

2. Open a command window in the Git repository directory you created in the DEV Gitora installation. 
For example i created a Git repository named 'DEVREPO' in my Gitora DEV installation.
The path (in my windows installation) would be:
C:\Program Files (x86)\Gerger\GitoraServer-DEV\repositories\gitora\DEVREPO

Now we need to use the Git 'remote' command to change the Git port.

Use 'remote -v' to lists all remote repositories that have been created in the repository.

C:\Program Files (x86)\Gerger\GitoraServer-DEV\repositories\gitora\DEVREPO>
"C:\Program Files (x86)\Gerger\GitoraServer-DEV\Git\bin\git.exe" remote -v

When you do this right after creating the remote repository in Gitora UI, you will not see any remote repository yet. This is because it is not yet created in Git, only configured in Gitora.

The easiest way to create it is just to open the remote pull window in the Gitora UI and fill in the remote repository details you want to pull from. That will create the Git remote definition.

Log into Gitora DEV, open the repository you want to pull to, and open the "Pull from remote" window (via menu "Remote commands - Pull").
Then select the remote Gitora, the Repository and Branch, but do not pull (it will not work anyway). Just cancel the screen after you selected the remote branch.

Now if you do 'remote -v' then you will see it listed, something like this:
TESTREPO_TESTREPO git:// (fetch)

3. To change the port we can use 'remote add'.
First, remove the current repository definition:

C:\Program Files (x86)\Gerger\GitoraServer-DEV\repositories\gitora\DEVREPO>
"C:\Program Files (x86)\Gerger\GitoraServer-DEV\Git\bin\git.exe" remote remove TESTREPO_TESTREPO

Then add the new definition, inluding the port (use the exact repository definition you got from 'remote -v', just add port 9419) like this:

C:\Program Files (x86)\Gerger\GitoraServer-DEV\repositories\gitora\DEVREPO>
"C:\Program Files (x86)\Gerger\GitoraServer-DEV\Git\bin\git.exe" remote add TESTREPO_TESTREPO git://

If you list the remote now, you should see the port number added
TESTREPO_TESTREPO git:// (fetch)

And now you should be able to pull from remote repo TESTREPO in Gitora TEST to the DEVREPO in Gitora DEV.

Have Fun!


  1. Hi @Michiel. Very good content. However, after having followed the exact steps you described, I still can't make the pull from remote repo work when running 2 Gitora installations on the same machine. I've changed the ports exactly as you recommended and when I do the pull from remote repo, the tomcat logs don't show any errors. In gitora I also get the 'Merge has been successful' message, but the code changes have not been copied over.
    Any ideas/hints on this?

    Below is an excerpt from the tomcat logs when I do the pull operation

    2018-05-30 16:06:51,567 WARN [http-bio-8081-exec-9] getBranchList
    2018-05-30 16:06:51,730 WARN [http-bio-8081-exec-6] show
    2018-05-30 16:13:04,068 WARN [http-bio-8081-exec-2] getRepoList
    2018-05-30 16:13:11,623 WARN [http-bio-8081-exec-5] getBranchList
    2018-05-30 16:13:15,756 WARN [http-bio-8081-exec-1] remote
    2018-05-30 16:13:15,968 WARN [http-bio-8081-exec-4] fetch
    2018-05-30 16:13:16,178 WARN [http-bio-8081-exec-3] getNewFiles
    2018-05-30 16:13:16,689 WARN [http-bio-8081-exec-10] getFileSchemaList
    2018-05-30 16:13:24,970 WARN [http-bio-8081-exec-9] validateLicense
    2018-05-30 16:13:25,019 WARN [http-bio-8081-exec-6] remote
    2018-05-30 16:13:25,179 WARN [http-bio-8081-exec-5] fetch
    2018-05-30 16:13:25,447 WARN [http-bio-8081-exec-8] merge
    2018-05-30 16:13:25,966 WARN [http-bio-8081-exec-1] read
    2018-05-30 16:13:25,981 WARN [http-bio-8081-exec-4] read
    2018-05-30 16:13:26,025 WARN [http-bio-8081-exec-3] commit
    2018-05-30 16:13:26,903 WARN [http-bio-8081-exec-10] getBranchList

  2. Hi Mark,
    Hard to tell why it doesn.t work without any error...
    Just to start somewhere:
    - i assume you have like dev repo and tet repo and want to pull from dev to test, right?
    - if you create a new object in dev and check it in, then go to Gitora test and do a remote pull, from the Gitora UI, do you see the new object in the remote pull screen?
    - if yes, you should see the new object in your Gitora test repo, is that correct?

    If the above works, then there is an issue with Gitora not exceuting the DDL in the database...

    Also have a look at the Gitora logs, maybe they show what is happening (there it is also logged what objects are pulled).

    By the way, what Gitora version do you use?
    I have written this for the previous version 2, so in version 3 i have not tested it yet (but i will update soon).