From 561ca14058c495f2860ef5b325afb70729f39a84 Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 13:59:43 +1100 Subject: [PATCH 1/7] ITPLAT-518 modify unit file for bbdc to not start foreground --- roles/product_startup/defaults/main.yml | 7 +++++++ roles/product_startup/templates/product.service.j2 | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/roles/product_startup/defaults/main.yml b/roles/product_startup/defaults/main.yml index 8a3695d..da7824c 100644 --- a/roles/product_startup/defaults/main.yml +++ b/roles/product_startup/defaults/main.yml @@ -10,9 +10,16 @@ atl_startup_script_map: stash: "bin/start-bitbucket.sh" crowd: "start_crowd.sh" +atl_stop_script_map: + jira: "bin/stop-jira.sh" + confluence: "bin/stop-confluence.sh" + stash: "bin/stop-bitbucket.sh" + crowd: "stop_crowd.sh" + atl_startup_exec_path: "{{ atl_product_installation_current }}/{{ atl_startup_script_map[atl_product_family] }}" atl_startup_exec_options: ["-fg"] atl_startup_systemd_params: [] +atl_stop_exec_path: "{{ atl_product_installation_current }}/{{ atl_stop_script_map[atl_product_family] }}" atl_systemd_service_dir_map: amazon: "/usr/lib/systemd/system" diff --git a/roles/product_startup/templates/product.service.j2 b/roles/product_startup/templates/product.service.j2 index ce2dff8..e432931 100644 --- a/roles/product_startup/templates/product.service.j2 +++ b/roles/product_startup/templates/product.service.j2 @@ -3,6 +3,9 @@ Description=Atlassian {{ atl_product_edition }} After=network-online.target [Service] +{% if (atl_product_family == "stash") %} +Type=forking +{% endif %} User={{ atl_product_user }} Group={{ atl_product_user }} StandardOutput=journal+console @@ -12,8 +15,14 @@ StandardError=journal+console {{ p }} {% endfor %} -{# Bitbucket DC sets up its service start/stop logging in a different way to all our other DC offerings and so we exclude it from having the catalina.out redirect #} -ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %}{% if (atl_product_family != "stash") %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1{% endif %} +{# Bitbucket DC sets up its service start/stop logging in a different way to all our other DC offerings and so we exclude it from having the catalina.out redirect and foreground startup #} +{% if (atl_product_family == "stash") %} +PIDFile={{ atl_product_home }}/log/bitbucket.pid +ExecStart={{ atl_startup_exec_path }} --no-search +ExecStop={{ atl_startup_exec_path }} +{% else -%} +ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1 +{% endif %} Restart=on-failure From ce7b3b3e4348511ec2e394dedd7c9dd17d04bdff Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 14:05:47 +1100 Subject: [PATCH 2/7] ITPLAT-518 remove fg from molecule test for bbdc --- roles/product_startup/molecule/bitbucket/tests/test_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/product_startup/molecule/bitbucket/tests/test_default.py b/roles/product_startup/molecule/bitbucket/tests/test_default.py index c895f75..6b9685c 100644 --- a/roles/product_startup/molecule/bitbucket/tests/test_default.py +++ b/roles/product_startup/molecule/bitbucket/tests/test_default.py @@ -9,7 +9,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_service_file(host): systemd_prefix = "/lib" if host.system_info.distribution == "ubuntu" else "/usr/lib" f = host.file(systemd_prefix+'/systemd/system/bitbucket.service') - assert f.contains("^ExecStart=/opt/atlassian/bitbucket/current/bin/start-bitbucket.sh -fg --no-search$") + assert f.contains("^ExecStart=/opt/atlassian/bitbucket/current/bin/start-bitbucket.sh --no-search$") assert f.contains("^UMask=0027$") assert f.contains("^LimitNOFILE=4096$") assert f.contains("^Environment=BITBUCKET_HOME=/media/atl/bitbucket$") From 62ae18d90b347f05f3a1fbdd414cc671c38bedcc Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 15:35:20 +1100 Subject: [PATCH 3/7] ITPLAT-518 adopt suggestions in PR comments --- aws_bitbucket_dc_node.yml | 3 +-- roles/product_startup/templates/product.service.j2 | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/aws_bitbucket_dc_node.yml b/aws_bitbucket_dc_node.yml index 3d8348e..96c19d8 100644 --- a/aws_bitbucket_dc_node.yml +++ b/aws_bitbucket_dc_node.yml @@ -22,7 +22,6 @@ - "Environment=JVM_MINIMUM_MEMORY={{ atl_jvm_heap }}" - "Environment=JVM_SUPPORT_RECOMMENDED_ARGS={{ atl_jvm_opts }}" atl_startup_exec_options: - - "-fg" - "--no-search" roles: @@ -37,5 +36,5 @@ - role: product_startup - role: bitbucket_dataset_restore when: atl_bitbucket_dataset_url is search ("(http|https)://") - + diff --git a/roles/product_startup/templates/product.service.j2 b/roles/product_startup/templates/product.service.j2 index e432931..ac52bc3 100644 --- a/roles/product_startup/templates/product.service.j2 +++ b/roles/product_startup/templates/product.service.j2 @@ -18,7 +18,7 @@ StandardError=journal+console {# Bitbucket DC sets up its service start/stop logging in a different way to all our other DC offerings and so we exclude it from having the catalina.out redirect and foreground startup #} {% if (atl_product_family == "stash") %} PIDFile={{ atl_product_home }}/log/bitbucket.pid -ExecStart={{ atl_startup_exec_path }} --no-search +ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} ExecStop={{ atl_startup_exec_path }} {% else -%} ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1 From 7c3dbd53aa05d3f597b4d6f50256d6c8df5ce31c Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 16:23:53 +1100 Subject: [PATCH 4/7] ITPLAT-518 fix molecule test for bbdc --- roles/product_startup/molecule/bitbucket/converge.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/product_startup/molecule/bitbucket/converge.yml b/roles/product_startup/molecule/bitbucket/converge.yml index dffb8ea..b0b462a 100644 --- a/roles/product_startup/molecule/bitbucket/converge.yml +++ b/roles/product_startup/molecule/bitbucket/converge.yml @@ -20,7 +20,6 @@ - "Environment=JVM_SUPPORT_RECOMMENDED_ARGS={{ atl_jvm_opts }}" atl_startup_exec_options: - - "-fg" - "--no-search" atl_startup_enable: false From 92baa3c2919328cfc76794e88dffda77ce6ab82d Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 16:57:02 +1100 Subject: [PATCH 5/7] ITPLAT-518 corrected stop script var name --- roles/product_startup/templates/product.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/product_startup/templates/product.service.j2 b/roles/product_startup/templates/product.service.j2 index ac52bc3..4e25de7 100644 --- a/roles/product_startup/templates/product.service.j2 +++ b/roles/product_startup/templates/product.service.j2 @@ -19,7 +19,7 @@ StandardError=journal+console {% if (atl_product_family == "stash") %} PIDFile={{ atl_product_home }}/log/bitbucket.pid ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} -ExecStop={{ atl_startup_exec_path }} +ExecStop={{ atl_stop_exec_path }} {% else -%} ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1 {% endif %} From 2ac2738985d08dc2ca8a461c512d6d16795f9ea4 Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Wed, 3 Mar 2021 17:44:59 +1100 Subject: [PATCH 6/7] ITPLAT-518 add templated whitespace after endif to ensure newline is placed --- roles/product_startup/templates/product.service.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/product_startup/templates/product.service.j2 b/roles/product_startup/templates/product.service.j2 index 4e25de7..83181ad 100644 --- a/roles/product_startup/templates/product.service.j2 +++ b/roles/product_startup/templates/product.service.j2 @@ -18,9 +18,9 @@ StandardError=journal+console {# Bitbucket DC sets up its service start/stop logging in a different way to all our other DC offerings and so we exclude it from having the catalina.out redirect and foreground startup #} {% if (atl_product_family == "stash") %} PIDFile={{ atl_product_home }}/log/bitbucket.pid -ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} +ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %}{{}} ExecStop={{ atl_stop_exec_path }} -{% else -%} +{% else %} ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1 {% endif %} From 7a992db9c4bc3d89cbdb3a0267cd149ce43d464b Mon Sep 17 00:00:00 2001 From: Brett Meehan Date: Thu, 4 Mar 2021 09:43:45 +1100 Subject: [PATCH 7/7] ITPLAT-518 add line between execstart and execstop to ensure newline after exec_options loop --- roles/product_startup/templates/product.service.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/product_startup/templates/product.service.j2 b/roles/product_startup/templates/product.service.j2 index 83181ad..9c16e66 100644 --- a/roles/product_startup/templates/product.service.j2 +++ b/roles/product_startup/templates/product.service.j2 @@ -18,7 +18,8 @@ StandardError=journal+console {# Bitbucket DC sets up its service start/stop logging in a different way to all our other DC offerings and so we exclude it from having the catalina.out redirect and foreground startup #} {% if (atl_product_family == "stash") %} PIDFile={{ atl_product_home }}/log/bitbucket.pid -ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %}{{}} +ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} + ExecStop={{ atl_stop_exec_path }} {% else %} ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %} >{{ atl_product_installation_current }}/logs/catalina.out 2>&1