#!/bin/bash # JAM 11-2020: starting from mar19 setup, try to let it run with hydra for fwdet-dev #------------------------------------------------- # CONFIGURATION serverDir=/home/hades-qa/online/5.34.38/feb24/online/server # location of hadesonlineserver.exe clientDir=/home/hades-qa/online/5.34.38/feb24/online/client # location of hadesonlineclient.exe setup=/home/hades-qa/bin/defall_feb24.sh # environment script of Hydra clientConf=/home/hades-qa/online/5.34.38/feb24/online/client/ClientConfig.xml # contains server host/port #------------------------------------------------- #------------------------------------------------- # get host and port from client config xml declare -a params ct=0 for par in $(perl ${serverDir}/analyzeConfig.pl $clientConf) do params[$ct]=$par ((ct+=1)) done serverHost=${params[0]} serverPort=${params[1]} export serverPort #------------------------------------------------- #------------------------------------------------- echo "Server host = $serverHost, port = $serverPort , found in $clientConf" echo "serverDir = $serverDir" echo "clientDir = $clientDir" echo "clientConf = $clientConf" echo "setup = $setup" #------------------------------------------------- #------------------------------------------------- # cleaning of eventually running processes,NOT CORRECT IF MULTIPLE INSTANCES ARE RUNNING!!!!!!!! #pkill -u hades-qa -f xterm #pkill -u hades-qa -f hadesonline #sleep 1 #pkill -9 -u hades-qa -f hadesonline #sleep 1 ### Clean up old instances of server,client and the belonging xterms depending on the serverport client=$(ps u | grep "hadesonlineclient.exe $clientConf" | grep -v grep) server=$(ps u | grep "hadesonlineserver.exe SUPER $serverHost $serverPort" | grep -v grep) # # if [ "$client" != "" ] then pid=$(echo $client | cut -d " " -f 2) kill -9 $pid fi # if [ "$server" != "" ] then pid=$(echo $server | cut -d " " -f 2) kill -9 $pid fi client=$(ps u | grep "OLM client $serverPort" | grep -v grep) server=$(ps u | grep "OLM server $serverPort" | grep -v grep) # # if [ "$client" != "" ] then pid=$(echo $client | cut -d " " -f 2) kill -9 $pid fi # if [ "$server" != "" ] then pid=$(echo $server | cut -d " " -f 2) kill -9 $pid fi #------------------------------------------------- #------------------------------------------------- # Jurek's favoured ERROR Handling :-) (can be commented) #xterm -g 20x10-0+0 -T "OLM ERROR" -bg red -fn r24 -e 'echo "ERROR"; sleep 100000'& #xterm -g 20x10-0-0 -T "OLM ERROR" -bg red -fn r24 -e 'echo "ERROR"; sleep 100000'& #------------------------------------------------- #------------------------------------------------- #sleep 1 echo "wait for port $serverPort to be free again after the server shut down" perl -e 'while (1) { $port=$ENV{serverPort}; $c="ss -tln | ag :$port"; $r=qx($c); last unless $r; sleep 1;} ' echo "port $serverPort is available for server" sleep 1; #perl -e 'while (1) { $c="ss -tln | ag :5678"; $r=qx($c); last unless $r; sleep 1;} ' nohup 2>/dev/null xterm -g 180x30-1600+30 -T "OLM server $serverPort" -bg white -fg black -e "${serverDir}/start_monServer $serverDir $serverHost $serverPort $setup; echo \"\nthere was an error\"; sleep 100" & sleep 20 echo "wait for port $serverPort to be accessible for the client" perl -e 'while (1) { $port=$ENV{serverPort}; $c="ss -tln | ag :$port"; $r=qx($c); last unless $r; sleep 1;} ' echo "port $serverPort is available for connection" nohup 2>/dev/null xterm -g 180x30+1600+30 -T "OLM client $serverPort" -bg yellow -fg black -e "${serverDir}/start_monClient $clientDir $clientConf $setup; echo \"\nthere was an error\"; sleep 100" & sleep 10