Stash is now known as Bitbucket Server.
See the

Unknown macro: {spacejump}

of this page, or visit the Bitbucket Server documentation home page.

This page only applies...

... if you are manually installing or upgrading Stash from an archive file.

If you're using the installer...

... you should read the Stash Getting started page instead.

We recommend that you use the Stash installer to install Stash as a service on Windows. It installs Stash as a service and creates items in the Windows 'Start' menu for starting and stopping Stash – see Getting started

The information on this page only applies if you are manually installing or upgrading Stash from an archive file. See Install Stash from an archive file.

For long-term use on a Windows server, Stash should be configured to run as a Windows service. This has the following advantages:

  • Stash will be automatically restarted when the operating system restarts. 
  • Stash is less likely to be accidentally shut down, as can happen if the console window Stash was manually started in is closed.
  • Stash logs are properly managed by the Windows service.

 

System administration tasks are not supported by Atlassian. These instructions are only provided as a guide.

 

Prerequisites

  • If you are using a 64-bit version of Windows, first ensure that Stash uses a 64-bit JVM (check by running java -version in a Command Prompt, and ensure that the JAVA_HOME system environment variable points to the 64-bit JVM), and then replace the 32-bit Tomcat binaries with their 64-bit counterparts in the <Stash installation directory>/bin directory:

    cd <STASH-INST/bin>
    rename tomcat8.exe tomcat8.exe.x86
    rename tcnative-1.dll tcnative-1.dll.x86
    rename tomcat8.exe.x64 tomcat8.exe
    rename tcnative-1.dll.x64 tcnative-1.dll
  • On any Windows operating system with User Account Control (UAC) such as Windows Vista or Windows 7, simply logging in to Windows with an Administrator account will not be sufficient to execute the script in the procedure below. You must either disable UAC or run 'cmd.exe' as an administrator (e.g. by right-clicking on 'cmd.exe' and choosing Run as administrator).
  • Ensure the JAVA_HOME variable is set to the root of your Java platform's installation directory.
    Note: Your JAVA_HOME cannot contain spaces, so the default Java installation directory of C:\Program Files\Java won't work.
  • Stash should be run from a local dedicated user account that does not have admin privileges and that has read, write and execute access to the Stash home directory and the <Stash installation directory>. See Git push operations extremely slow on Windows.
  • When you run Stash as a Windows service, all settings in setenv.bat are ignored. Ensure that you have set STASH_HOME as a system environment variable, before running the service.bat script.
  • If you upgraded Stash from version 1.x to 2.x and Stash stopped running as a service you will need to reinstall the service according to instructions in the Stash upgrade guide.

Set up Stash as a Windows service

The information in this section only applies if you are manually installing Stash as a Windows service. Alternatively, you can use the Stash installer for Windows to install Stash as a service – see Running the Stash installer.

To run Stash as a Windows service:

  1. Stop Stash.
  2. Create a system environment variable with STASH_HOME as the Variable name and the absolute path to your Stash home directory as the Variable value. Don't use a trailing backslash. Note that the Stash home directory should not be located inside the <Stash installation directory>. You must do this step before running the service.bat script in Step 5 below.
  3. Open a Command Prompt (as an Administrator – see the 'Prerequisites' section above).
  4. Change directory to the Stash installation directory and then into the bin subdirectory. If a directory in the path has spaces (e.g. C:\Program Files\..), use its eight-character equivalent (e.g. C:\Progra~1\..).
  5. Run the following commands:

    > service.bat install
    > tomcat8 //US//AtlassianStash --Startup auto

    This will create a service with the name "AtlassianStash" and a display name of "Atlassian Stash".  If you would like to customize the name you can instead run:

    > service.bat install MyName
    > tomcat8 //US//MyName --Startup auto

    This will create the service as "MyName" with a display name of "Atlassian Stash MyName".

  6. Run the following command to increase the amount of memory that Stash can use (the default is 768 Mb):

    > tomcat8 //US//service_name --JvmMx 1024
  7. Verify that the Stash service comes back up after restarting the machine.

Here is an example:

C:\Program Files (x86)\atlassian-stash-2.0.0\bin>service.bat install
Installing the service 'AtlassianStash' ...
Using CATALINA_HOME:    "C:\Program Files (x86)\atlassian-stash-2.0.0"
Using CATALINA_BASE:    "C:\Program Files (x86)\atlassian-stash-2.0.0"
Using JAVA_HOME:        "C:\Java\jre6"
Using JVM:              "auto"
The service 'AtlassianStash' has been installed.
C:\Program Files (x86)\atlassian-stash-2.0.0\bin>tomcat8.exe //US//AtlassianStash --Startup auto
C:\Program Files (x86)\atlassian-stash-2.0.0\bin>tomcat8.exe //US//AtlassianStash --JvmMx 1024
 
C:\Program Files (x86)\atlassian-stash-2.0.0\bin>net start AtlassianStash
The Atlassian Stash service is starting.
The Atlassian Stash service was started successfully.

Troubleshooting

  • If your service fails to start with "code 4", make sure you ran service.bat install in a Command Prompt running as an Administrator.
  • No labels