summaryrefslogtreecommitdiff
path: root/bin/taler-deployment-config-instances
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-28 17:47:26 +0200
committerMS <ms@taler.net>2021-05-28 17:50:53 +0200
commit76029d3e9c8bc9e41d27fca7d84106bfa4d9aaea (patch)
tree837169c1d077cbe70446c3f10992e30889ffbe04 /bin/taler-deployment-config-instances
parent3349d05464c2826ed6c333930a11e8e4bfeff46a (diff)
downloaddeployment-76029d3e9c8bc9e41d27fca7d84106bfa4d9aaea.tar.gz
deployment-76029d3e9c8bc9e41d27fca7d84106bfa4d9aaea.tar.bz2
deployment-76029d3e9c8bc9e41d27fca7d84106bfa4d9aaea.zip
Restarting merchant with MERCHANT_AUTH_TOKEN in env.
More checks to see whether the merchant restarted correctly.
Diffstat (limited to 'bin/taler-deployment-config-instances')
-rwxr-xr-xbin/taler-deployment-config-instances63
1 files changed, 50 insertions, 13 deletions
diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances
index 162ae52..06199d8 100755
--- 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()