taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

commit 97705eca5310cfef2dbe44df691f01dbe36ab0af
parent efcc4c7015181e57159920695ba86d596b5b4e5d
Author: MS <ms@taler.net>
Date:   Fri, 28 May 2021 18:27:08 +0200

fix waiting for merchant to be up

Diffstat:
Mbin/taler-deployment-config-instances | 53++++++++++++++++++++++++++++-------------------------
1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances @@ -24,11 +24,30 @@ def expect_env(name): exit(1) return val -def wait_merchant(): - for proc in psutil.process_iter(): - if proc.name() == "taler-merchant-httpd" and proc.username == getuser(): - break - sleep(1) +def wait_merchant_up(): + # Check it started correctly and it is ready to serve requests. + checks = 10 + while checks > 0: + + try: + resp = requests.get(urljoin(MERCHANT_BACKEND_BASE_URL, "/config"), timeout=1.5) + except Exception: + sleep(1) + checks -= 1 + continue + + if resp.status_code != 200: + sleep(1) + checks -= 1 + continue + + # Ready. + break + + if checks == 0: + print("Could not start the merchant (with TALER_MERCHANT_TOKEN in the env).") + exit(1) + MERCHANT_BACKEND_BASE_URL = expect_env("TALER_ENV_MERCHANT_BACKEND") TALER_ENV_NAME = expect_env("TALER_ENV_NAME") @@ -111,25 +130,7 @@ def ensure_default_instance(): # Start the merchant natively. merchant = Popen(["taler-merchant-httpd"], env=env_with_token) - # Check it started correctly and it is ready to serve requests. - checks = 10 - while checks > 0: - - try: - resp = requests.get(urljoin(MERCHANT_BACKEND_BASE_URL, "/config"), timeout=1.5) - except Exception: - sleep(1) - checks -= 1 - continue - - if resp.status_code != 200: - sleep(1) - checks -= 1 - continue - - if checks == 0: - print("Could not start the merchant (with TALER_MERCHANT_TOKEN in the env).") - exit(1) + wait_merchant_up() ensure_instance( "default", @@ -145,7 +146,9 @@ def ensure_default_instance(): system("taler-deployment-arm -i taler-merchant") ensure_default_instance() -wait_merchant() +# Needs to wait here since the merchant got lastly restarted via ARM, +# in the previous operation. +wait_merchant_up() ensure_instance( "blog",