commit 76029d3e9c8bc9e41d27fca7d84106bfa4d9aaea
parent 3349d05464c2826ed6c333930a11e8e4bfeff46a
Author: MS <ms@taler.net>
Date: Fri, 28 May 2021 17:47:26 +0200
Restarting merchant with MERCHANT_AUTH_TOKEN in env.
More checks to see whether the merchant restarted correctly.
Diffstat:
1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances
@@ -80,31 +80,68 @@ def ensure_instance(instance_id, name, payto_uris, auth):
else:
exit(1)
+def is_merchant_running():
+ for proc in psutil.process_iter():
+ if proc.name() == "taler-merchant-httpd" and proc.username == getuser():
+ return True
+ return False
+
+
def ensure_default_instance():
- system("taler-deployment-arm -k taler-merchant")
- # Wait that merchant actually terminated.
- still_running = True
- while still_running:
- still_running = False
- for proc in psutil.process_iter():
- if proc.name() == "taler-merchant-httpd" and proc.username == getuser():
- still_running = True
- sleep(1)
- break
+ # Assumed is managed by ARM
+ if is_merchant_running():
+ system("taler-deployment-arm -k taler-merchant")
+
+ checks = 10
+ while checks > 0:
+ if is_merchant_running():
+ sleep(1)
+ checks--
+ continue
+ break
+
+ if checks == 0:
+ print("Could not stop the running merchant.")
+ exit(1)
+ # ARM is _not_ running the merchant at this point.
env_with_token = environ.copy()
env_with_token["TALER_MERCHANT_TOKEN"] = TALER_ENV_FRONTENDS_APITOKEN
+
+ # Start the merchant natively.
merchant = Popen(["taler-merchant-httpd"], env=env_with_token)
- wait_merchant()
+ # Check it started correctly and it is ready to serve requests.
+ checks = 10
+ while checks > 0:
+
+ try:
+ resp = get(MERCHANT_BACKEND_BASE_URL, timeout=1.5):
+ except Exception:
+ sleep(1)
+ checks--
+ continue
+
+ if resp.status_code != 200:
+ sleep(1)
+ checks--
+ continue
+
+ if checks == 0:
+ print("Could not start the merchant (with TALER_MERCHANT_TOKEN in the env).")
+ exit(1)
+
ensure_instance(
- "default",
+ "default",
"default",
payto_uris=[f"payto://x-taler-bank/bank.{TALER_ENV_NAME}.taler.net/Taler"],
- auth=dict(method="token", token="secret-token:sandbox")
+ auth=dict(method="token", token=TALER_ENV_FRONTENDS_APITOKEN)
)
+
merchant.terminate()
merchant.wait()
+
+ print("Starting the merchant again via ARM")
system("taler-deployment-arm -i taler-merchant")
ensure_default_instance()