From 1dbee81e8663b58b7edcbb4c2a83a8e5a90f9e31 Mon Sep 17 00:00:00 2001 From: qo-op Date: Sat, 13 Jun 2020 13:11:20 +0200 Subject: [PATCH] ssb-server control & restart --- cron_MINUTE.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cron_MINUTE.sh b/cron_MINUTE.sh index 3957869..6e0e20f 100755 --- a/cron_MINUTE.sh +++ b/cron_MINUTE.sh @@ -17,13 +17,21 @@ ME="${0##*/}" export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running" source /home/$YOU/.profile export IPFSNODEID=$(ipfs id -f='\n') || er+=" ipfs id problem" -export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 5 sbotc whoami | jq -r .id) +export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 8 sbotc whoami | jq -r .id) if [[ "$WHOAMI" == "" ]]; then ### oasis ssb-server not responding!!! - echo "sboc <-> SSB-SERVER IMPOSSIBLE..." - kill -9 $(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') - # while true; do ssb-server start; sleep 3; done + echo "sbotc <-> ssb-server communication broken... restarting ssb-server !" + + ssb_process=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') + kill -9 $ssb_process + + sleep 5 + ssb_newprocess=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') + + if [[ ! $ssb_newprocess ]]; then + while true; do ssb-server start; sleep 3; done & + fi # kill -9 $(ps auxf --sort=+utime | grep -w 'oasis' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') # oasis --allow-host oasis.astroport.com --host oasis.astroport.com &