Bitbucket Server を Windows サービスとして実行する

このページでは、Bitbucket Server を Windows サービスとして実行する方法について説明します。

Bitbucket Server を Windows にサービスとしてインストールするには、Bitbucket Server インストーラーを使用することをお勧めします。インストーラーは、Windows の [スタート] メニューに Bitbucket Server の起動と停止を行うための項目を作成します。詳細は、「はじめに」を参照してください。 

Bitbucket Server をアーカイブ ファイルから手動でインストールまたはアップグレードする場合は「Bitbucket Server をアーカイブ ファイルからインストールする」を参照してください。

Windows サーバーでの長期的な使用の場合、Bitbucket Server を Windows サービスとして実行するように構成することをおすすめします。これには以下のメリットがあります。

  • オペレーティング システムを再起動すると、Bitbucket Server が自動的に再起動されます。 
  • Bitbucket Server を誤ってシャットダウンする可能性が低くなります (Bitbucket Server を手動で起動した場合、コンソール ウィンドウを閉じるとシャットダウンされるため)。
  • Bitbucket Server のログは Windows サービスにより適切に管理されます。

アトラシアンではシステム管理タスクはサポートしていません。これらの手順はガイドとしてのみ提供されています。

前提条件

  • On any Windows operating system with User Account Control (UAC) such as 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 then choose Run as administrator).
  • Ensure the JAVA_HOME variable is set to the root of your Java platform's installation directory. 

Your JAVA_HOME cannot contain spaces, so the default Java installation directory of C:\Program Files\Java won't work.

  • When you run Bitbucket Server as a Windows service, all settings in _start-webapp.bat are ignored. Ensure that you have set BITBUCKET_HOME as a system environment variable, before running the service.bat script.

Bitbucket Server を Windows サービスとして実行する

バージョン 4.6 の時点で、Windows サービスとして Bitbucket Server をインストールするには、Bitbucket Server サービス (アプリケーションの機能を提供) と、バンドルされる Bitbucket Elasticsearch サービス (コンテンツのインデックス作成および検索機能を提供) の 2 つのサービスをインストールする必要があります。

Bitbucket Server を Windows サービスとしてインストールする方法

  1. Bitbucket Server を停止します
  2. Create a system environment variable with BITBUCKET_HOME as 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.bat script in Step 5 below.
  3. バンドルされている Bitbucket Elasticsearch サービスに必要な次のシステム環境変数を作成します。

    変数名変数の値
    LOG_DIR
    %BITBUCKET_HOME%\log\search
    DATA_DIR
    %BITBUCKET_HOME%\shared\search\data
    CONF_DIR
    %BITBUCKET_HOME%\shared\search
  4. Open a Command Prompt (as an administrator – see the Prerequisites section above).

  5. 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. C:\Progra~1\..).
  6. 次のコマンドを実行し、サービス名を "BITBUCKET"、表示名を "Atlassian Bitbucket Server BITBUCKET" と指定してサービスを作成します。

    service.bat install

    名前をカスタマイズしたい場合、次のコマンドを実行できます。

    service.bat install MyName

    これにより、サービス名が "MyName"、表示名が "Atlassian Bitbucket Server MyName" のサービスが作成されます。

  7. Change directory to <Bitbucket Server installation directory>\elasticsearch.
  8. Bitbucket Server の新しいインスタンスをインストールする場合、または Bitbucket Server 4.5 以前からアップグレードする場合は、次のコマンドを実行して、テンプレートの Elasticsearch 構成ファイルを Bitbucket ホーム ディレクトリにコピーします。

    robocopy /S config-template %BITBUCKET_HOME%\shared\search
  9. Change directory to <Bitbucket Server installation directory>\elasticsearch\bin.

  10. 次のコマンドを実行し、サービス名を "BITBUCKET_SEARCH"、表示名を "Atlassian Bitbucket Elasticsearch (BITBUCKET_SEARCH)" と指定してサービスを作成します。

    service.bat install

    名前をカスタマイズする場合は、次のコマンドを実行してもかまいません。

    service.bat install MyName

    これにより、サービス名が "MyName"、表示名が "Atlassian Bitbucket Elasticsearch (MyName)" のサービスが作成されます。

  11. マシンの再起動後に Bitbucket Server および Bitbucket Elasticsearch サービスが起動することを確認します。

この手順を正常に完了した場合の出力例は次のようになります。

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 install in a Command Prompt running as an Administrator.

最終更新日: 2023 年 2 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.