Bitbucket Server を Windows サービスとして実行する
This page describes how to run Bitbucket Server as a Windows service, and only applies if you are manually installing or upgrading Bitbucket Server from an archive file. See the page Install Bitbucket Server from an archive file for more details.
We recommend that you use the Bitbucket Server installer to install Bitbucket Server as a service on Windows. It installs Bitbucket Server as a service and creates items in the Windows 'Start' menu for starting and stopping Bitbucket Server – see Getting started for more details.
For long-term use on a Windows server, Bitbucket Server should be configured to run as a Windows service. This has the following advantages:
- Bitbucket Server will be automatically restarted when the operating system restarts.
- Bitbucket Server is less likely to be accidentally shut down, as can happen if the console window Bitbucket Server was manually started in is closed.
- Bitbucket Server のログは Windows サービスにより適切に管理されます。
System administration tasks are not supported by Atlassian. These instructions are only provided as a guide.
If you are using a 64-bit version of Windows, first ensure that Bitbucket Server uses a 64-bit JVM (check by running
java -versionin a Command Prompt, and ensure the
JAVA_HOMEsystem environment variable points to the 64-bit JVM), and then replace the 32-bit Tomcat binaries with their 64-bit counterparts in the
<Bitbucket Server installation directory>/bin directory:
cd <BITBUCKET-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.exeas an administrator (e.g. by right-clicking on cmd.exe then choose Run as administrator).
JAVA_HOMEvariable is set to the root of your Java platform's installation directory.
JAVA_HOMEcannot contain spaces, so the default Java installation directory of
C:\Program Files\Javawon't work.
- Bitbucket Server 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 Bitbucket home directory and the <
Bitbucket Server installation directory>. See Git push operations extremely slow on Windows.
- When you run Bitbucket Server as a Windows service, all settings in
setenv.batare ignored. Ensure that you have set
BITBUCKET_HOMEas a system environment variable, before running the
- If you upgraded Bitbucket Server from version 1.x to 2.x and Bitbucket Server stopped running as a service you will need to reinstall the service according to instructions in the Bitbucket Server upgrade guide.
Set up Bitbucket Server as a Windows service
The information in this section only applies if you are manually installing Bitbucket Server as a Windows service. Alternatively, you can use the Bitbucket Server installer for Windows to install Bitbucket Server as a service – see Running the Bitbucket Server installer .
As of version 4.6, installing Bitbucket Server as a Windows service requires installing two services: the Bitbucket Server service, which provides application functionality, and the bundled Bitbucket Elasticsearch service, which provides content indexing and search functionality.
To install Bitbucket Server as a Windows service
- Stop Bitbucket Server.
- Create a system environment variable with
BITBUCKET_HOMEas the Variable name and the absolute path to your Bitbucket Server home directory as the Variable value. Don't use a trailing backslash. Note that the Bitbucket home directory should not be located inside the
<Bitbucket Server installation directory>. You must do this step before running the
service.batscript in Step 5 below.
Create these system environment variables required for the bundled Bitbucket Elasticsearch service:
変数名 Variable value
Open a Command Prompt (as an
administrator– see the Prerequisites section above).
- Change directory to
<Bitbucket Server installation directory>\bin. If a directory in the path has spaces (e.g.
C:\Program Files\..), use its eight-character equivalent (e.g.
次のコマンドを実行し、サービス名を "BITBUCKET"、表示名を "Atlassian Bitbucket Server BITBUCKET" と指定してサービスを作成します。
If you would like to customize the name you can instead run:
service.bat install MyName
This creates a service called "MyName" with a display name of "Atlassian Bitbucket Server MyName".
Increase the amount of memory that Bitbucket Server can use (the default is 768 Mb) by running this command:
tomcat8 //US//service_name --JvmMx 1024
- Change directory to
<Bitbucket Server installation directory>\elasticsearch.
If you are installing a new instance of Bitbucket Server, or are upgrading from Bitbucket Server 4.5 or earlier, copy the template Elasticsearch config files over to your Bitbucket home directory by running the following command:
robocopy /S config-template %BITBUCKET_HOME%\shared
Change directory to
<Bitbucket Server installation directory>\elasticsearch\bin.
次のコマンドを実行し、サービス名を "BITBUCKET_SEARCH"、表示名を "Atlassian Bitbucket Elasticsearch (BITBUCKET_SEARCH)" と指定してサービスを作成します。
service.bat install MyName
This creates the service "MyName" with a display name of "Atlassian Bitbucket Elasticsearch (MyName)".
- Verify the Bitbucket Server and Bitbucket Elasticsearch services start after restarting the machine.
Here is an example of the output you can expect after successfully completed this procedure
C:\Atlassian\atlassian-bitbucket-4.6.3\bin>service.bat install Installing the service 'BITBUCKET' ... Using CATALINA_HOME: "C:\Atlassian\atlassian-bitbucket-4.6.3" Using CATALINA_BASE: "C:\Atlassian\atlassian-bitbucket-4.6.3" Using JAVA_HOME: "c:\java\jdk1.8.0_92" Using JRE_HOME: "c:\java\jdk1.8.0_92\jre" Using JVM: "c:\java\jdk1.8.0_92\jre\bin\server\jvm.dll" The service 'BITBUCKET' has been installed. C:\Atlassian\atlassian-bitbucket-4.6.3\bin>cd ..\elasticsearch\bin C:\Atlassian\atlassian-bitbucket-4.6.3\elasticsearch\bin>service.bat install Installing service : "BITBUCKET_SEARCH" Using JAVA_HOME (64-bit): "c:\java\jdk1.8.0_92" The service 'BITBUCKET_SEARCH' has been installed. C:\Atlassian\atlassian-bitbucket-4.6.3\elasticsearch\bin>net start BITBUCKET_SEARCH The Atlassian Bitbucket Elasticsearch 2.3.1 (BITBUCKET_SEARCH) service is starting. The Atlassian Bitbucket Elasticsearch 2.3.1 (BITBUCKET_SEARCH) service was started successfully. C:\Atlassian\atlassian-bitbucket-4.6.3\elasticsearch\bin>net start BITBUCKET The Atlassian Bitbucket BITBUCKET service is starting. The Atlassian Bitbucket BITBUCKET service was started successfully.
- If your service fails to start with
code 4, ensure you ran
service.bat installin a Command Prompt running as an Administrator.