Monday, November 21, 2016

Start Gitora as a Windows service

In our company, we use Gitora on a shared development database.
So, every developer needs to access this shared Gitora instance.

By default, Gitora does not run as a service, so in order for our developers to access Gitora, we need to log in to the server, start Gitora and leave the session running. Obviously this is not ideal.

So we want to run Gitora as a windows service (we installed Gitora on a Windows 12 server).
This blog shows you how to do this.

Download missing Tomcat files 


In order to create the windows service, we need 2 files that are not present in the Gitora installation.
So first we need to download the correct Tomcat version.
For Gitora 2.0 this is version 7.0.69.
You can download it from here:
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.69/bin/
Download the 'apache-tomcat-7.0.69-windows-x86.zip' file.

Unzip and copy 2 files from /BIN
service.bat
tomcat7.exe

Copy these 2 files to your Gitora installation \apache-tomcat-7.0.69\bin\ folder.

Modify service.bat


We need to edit the service.bat file we just copied to prepare it for the service creation.

Change the service name for the Gitora service

By default, the service is installed with a name starting with 'Apache Tomcat 7.0 '.
If you want a nicer name for your service, we need to edit the service.bat file,
Find the section :checkUser and remove the text 'Apache Tomcat 7.0' from the DISPLAYNAME, like this:


Add the PATH environment variable

Gitora also needs a correct PATH environment variable, so we need to add an -- Environment parameter to the service.bat file. The PATH points to your Gitora installation \Git\bin folder, in my case it is:


Set JvmMs and JvmMx values

Set the values for  --JvmMs and  --JvmMx parameters to the desired values.
Default for Gitora is 1024 (as in Gitora tomcat-startup.bat).


Auto start service

Add --Startup to have the service start automatically.


With the above changes, the service.bat section with parameters will look like this:

NOTE: Make sure you add the ' ^' after the startup parameter if it is not the last one. 

Create the service


The easiest way to create the service is to make a bat file for the command we need to run.
Copy the tomcat_startup.bat (it already has some commands we need) and rename it for example to install_service.bat

Edit the new install_service.bat file.
Keep the lines that set the CATALINA_HOME and JRE_HOME and remove the rest.

Add the command to install the service to the service.bat file we just edited.
(cmd /k will keep the command window open so you can check the result)
It should result in something like this (modify the service name, i set it to 'Gitora-DEV' in this example):


Double click the install_service.bat file to create the service. You should see something like this:


Start the service


Now the service is running and you can safely exit the server session or reboot the server without having to think about starting Gitora again.

Have fun!

2 comments:

  1. hello Michiel, thanks for your blog, keep posting!
    I am going to try Gitora at my work too, your blog will help me a lot

    ReplyDelete