From 2877920de2dc6c544ca3ff3b247fcd06efb292a8 Mon Sep 17 00:00:00 2001 From: MS Date: Sat, 29 May 2021 08:53:11 +0200 Subject: Improve process termination --- bin/taler-deployment-config-instances | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances index ad1feec..27c5c17 100755 --- a/bin/taler-deployment-config-instances +++ b/bin/taler-deployment-config-instances @@ -47,11 +47,11 @@ def wait_merchant_up(): # Ready. print("Merchant is up and running") - break + return True if checks == 0: - print("Could not start the merchant (with TALER_MERCHANT_TOKEN in the env).") - exit(1) + print("Merchant is not correctly serving requests.") + return False MERCHANT_BACKEND_BASE_URL = expect_env("TALER_ENV_MERCHANT_BACKEND") @@ -140,7 +140,10 @@ def ensure_default_instance(): # Start the merchant natively. merchant = Popen(["taler-merchant-httpd"], env=env_with_token) - wait_merchant_up() + if not wait_merchant_up(): + merchant.terminate() + merchant.wait() + exit(1) print("Merchant started successfully, creating the default instance now.") ensure_instance( @@ -149,17 +152,20 @@ def ensure_default_instance(): payto_uris=[f"payto://x-taler-bank/bank.{TALER_ENV_NAME}.taler.net/Taler"], auth=dict(method="token", token=TALER_ENV_FRONTENDS_APITOKEN) ) - + # Native process can be terminated now. merchant.terminate() merchant.wait() print("Merchant terminated, restarting it via ARM now.") - + # Restarting the official ARM merchant. system("taler-deployment-arm -i taler-merchant") ensure_default_instance() + # Needs to wait here since the merchant got lastly restarted via ARM, # in the previous operation. -wait_merchant_up() +if not wait_merchant_up(): + system("taler-deployment-arm -k taler-merchant") + exit(1) ensure_instance( "blog", -- cgit v1.2.3