gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-grid5k] 59/73: fix taler-perf.sh, improve other scripts


From: gnunet
Subject: [taler-grid5k] 59/73: fix taler-perf.sh, improve other scripts
Date: Tue, 14 Dec 2021 15:10:41 +0100

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository grid5k.

commit 4ca1029111b9c5d91a290e28362ffd3d7360cfd6
Author: Boss Marco <bossm8@bfh.ch>
AuthorDate: Fri Dec 10 18:20:16 2021 +0100

    fix taler-perf.sh, improve other scripts
---
 experiment/README.md             |  3 ++
 experiment/scripts/exchange.sh   |  2 ++
 experiment/scripts/monitor.sh    | 62 +++++++++++++++-------------------------
 experiment/scripts/proxy.sh      | 41 +++++++++++++-------------
 experiment/scripts/taler-perf.sh |  1 +
 5 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/experiment/README.md b/experiment/README.md
index 717c9cd..6b190e9 100644
--- a/experiment/README.md
+++ b/experiment/README.md
@@ -35,6 +35,9 @@ TODO - DOES NOT WORK YET - DNS host needs to be known ..
 * Click (Re)Run ESpec for the wallet job (type directory)
 * Run `talet-perf update prometheus` on any deployed node to make prometheus 
aware of the freshly added wallets
 
+**NOTE** On `taler-perf`, when not using a terminal opened from jFed make sure 
to forward the ssh-agent
+         to make the script work. E.g. `ssh -A graoully-3.nancy.g5k` 
+
 ## Rebuild Taler Binaries
 
 To quickly test fixes of new commits in gnunet,exchange,merchant and wallet, 
there is a script `scripts/instal.sh`
diff --git a/experiment/scripts/exchange.sh b/experiment/scripts/exchange.sh
index 6300b45..d896d62 100755
--- a/experiment/scripts/exchange.sh
+++ b/experiment/scripts/exchange.sh
@@ -50,6 +50,8 @@ function init_exchanges() {
 function start_exchanges() {
   RUNNING=$(ps -aux | grep "[taler]-exchange-httpd" | wc -l)
 
+  # We cant do seq 0 n, if n=0 it would yield 0, thus do seq n and decrement
+  # by one, then seq 0 yields nothing
   for i in $(seq ${1}); do
     let "i+=${RUNNING}-1" || true
     let "i+=10000"
diff --git a/experiment/scripts/monitor.sh b/experiment/scripts/monitor.sh
index 9992827..ddbce61 100755
--- a/experiment/scripts/monitor.sh
+++ b/experiment/scripts/monitor.sh
@@ -49,44 +49,23 @@ function configure_prometheus_and_exporters() {
 
 
 function add_wallet_nodes_to_prometheus() {
-  if [[ "${ENABLE_EXPORTERS}" == "true" ]]; then
-
-    if [[ "$1" == "init" ]]; then
-      cat /etc/monitor/node-exporters.yaml.tpl | envsubst >> 
/etc/monitor/prometheus.yaml
+  for WALLET in $(get_wallet_domains); do
+    if ! grep -q "${WALLET_DOMAIN//\*/${WALLET}}:9100" 
/etc/monitor/prometheus.yaml; 
+    then
+      sed -i "/<WALLETS_HERE>/a \ \ \ \ \ \ - 
'${WALLET_DOMAIN//\*/${WALLET}}:9100'" \
+              /etc/monitor/prometheus.yaml
     fi
-
-    for WALLET in $(get_wallet_domains); do
-
-      if ! grep -q "${WALLET_DOMAIN//\*/${WALLET}}:9100" 
/etc/monitor/prometheus.yaml; 
-      then
-        sed -i "/<WALLETS_HERE>/a \ \ \ \ \ \ - 
'${WALLET_DOMAIN//\*/${WALLET}}:9100'" \
-                /etc/monitor/prometheus.yaml
-      fi
-
-    done
-
-  fi
+  done
 }
 
 function add_exchanges_to_prometheus() {
-  if [[ "$1" == "init" ]]; then 
-    cat /etc/monitor/exchange-exporters.yaml.tpl >> 
/etc/monitor/prometheus.yaml
-
-    for i in $(seq $((${NUM_EXCHANGE_PROCESSES:-10}-1))); do
-      let "i+=10000"
-      sed -i "/<EXCHANGES_HERE>/a  \ \ \ \ \ \ - '${EXCHANGE_DOMAIN}:${i}'" \
+  for EXCH in $(get_exchanges); do 
+    if ! grep -q "${EXCH}" /etc/monitor/prometheus.yaml;
+    then
+      sed -i "/<EXCHANGES_HERE>/a  \ \ \ \ \ \ - '${EXCH}'" \
               /etc/monitor/prometheus.yaml
-    done
-
-  else
-    for EXCH in $(get_exchanges); do 
-      if ! grep -q "${EXCH}" /etc/monitor/prometheus.yaml;
-      then
-        sed -i "/<EXCHANGES_HERE>/a  \ \ \ \ \ \ - '${EXCH}'" \
-                /etc/monitor/prometheus.yaml
-      fi
-    done
-  fi
+    fi
+  done
 }
 
 function remove_exchanges_from_prometheus() {
@@ -117,15 +96,20 @@ function init_monitor() {
   # Proxy takes longer to start
   wait_for_keys "${PROXY_DOMAIN}"
   
-  # Wait that the nginx proxy has the exchanges configured
-  sleep 1
-  add_wallet_nodes_to_prometheus "init"
-  add_exchanges_to_prometheus "init"
+  if [[ "${ENABLE_EXPORTERS}" == "true" ]]; then
+    cat /etc/monitor/node-exporters.yaml.tpl | envsubst >> 
/etc/monitor/prometheus.yaml
+    add_wallet_nodes_to_prometheus
+  fi
+
+  cat /etc/monitor/exchange-exporters.yaml.tpl >> /etc/monitor/prometheus.yaml
+  add_exchanges_to_prometheus
 
   systemctl restart prometheus-nginx-exporter \
                     prometheus-postgres-exporter \
                     prometheus
 
+  # wait, otherwise reload will abort restart of prometheus
+  sleep 1
 }
   
 case $1 in
@@ -133,8 +117,8 @@ case $1 in
     init_monitor
     ;;
   start)
-    add_wallet_nodes_to_prometheus ""
-    add_exchanges_to_prometheus ""
+    add_wallet_nodes_to_prometheus
+    add_exchanges_to_prometheus
     ;;
   stop-exchanges)
     remove_exchanges_from_prometheus $2
diff --git a/experiment/scripts/proxy.sh b/experiment/scripts/proxy.sh
index f6543c1..75c38cb 100755
--- a/experiment/scripts/proxy.sh
+++ b/experiment/scripts/proxy.sh
@@ -1,18 +1,29 @@
 #!/bin/bash
 set -eux
 
-  source ~/scripts/helpers.sh
-  
-function setup_config() {
-  sed "/<SERVERS_HERE>/a \ \ server ${EXCHANGE_DOMAIN}:80;" \
-       /etc/nginx/sites-available/proxy > /etc/nginx/sites-enabled/proxy
+source ~/scripts/helpers.sh
+
+function add_exchanges() {
+  ADDED=$(\
+    grep -r "  server ${EXCHANGE_DOMAIN}:" /etc/nginx/sites-enabled/proxy | \
+    wc -l 
+  )
   
-  # We want n processes, one is already enabled on port 80
-  for i in $(seq $((${NUM_EXCHANGE_PROCESSES:-10}-1)) ); do
-    let "PORT=i+10000"
-    sed -i "/<SERVERS_HERE>/a \ \ server ${EXCHANGE_DOMAIN}:${PORT};" \
-          /etc/nginx/sites-enabled/proxy
+  for i in $(seq ${1}); do
+    if [[ "${ADDED}" -eq "0" ]] && [[ "${i}" -eq "1" ]]; then
+      # The first exchange to add is the default one from the target on port 80
+      i="80"
+    else 
+      let "i+=${ADDED}-1"
+      let "i+=10000"
+    fi
+    sed -i "/<SERVERS_HERE>/a \ \ server ${EXCHANGE_DOMAIN}:${i};" \
+            /etc/nginx/sites-enabled/proxy
   done
+}
+  
+function setup_config() {
+  add_exchanges ${NUM_EXCHANGE_PROCESSES}
   
   # Nginx will log to our rsyslog directly an then from there it will be 
   # redirected to promtail - there was an issue doing it directly that's
@@ -45,16 +56,6 @@ function init_proxy() {
   systemctl restart nginx
 }
 
-function add_exchanges() {
-  ADDED=$(grep -r "  server ${EXCHANGE_DOMAIN}:" 
/etc/nginx/sites-enabled/proxy | wc -l)
-  
-  for i in $(seq ${1}); do
-    let "i+=${ADDED}-1"
-    let "i+=10000"
-    sed -i "/<SERVERS_HERE>/a \ \ server ${EXCHANGE_DOMAIN}:${i};" \
-            /etc/nginx/sites-enabled/proxy
-  done
-}
 
 function remove_exchanges() {
   TO_STOP=$(\
diff --git a/experiment/scripts/taler-perf.sh b/experiment/scripts/taler-perf.sh
index 8171e0b..9414d4b 100644
--- a/experiment/scripts/taler-perf.sh
+++ b/experiment/scripts/taler-perf.sh
@@ -127,6 +127,7 @@ case "$1" in
   update)
     shift
     update_processes $@
+    ;;
   rebuild)
     shift
     rebuild

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]