-
Notifications
You must be signed in to change notification settings - Fork 1
/
execute-analysis-and-visualization.sh
executable file
·91 lines (72 loc) · 2.37 KB
/
execute-analysis-and-visualization.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# configuration
echo "Script does not work, as command line API of analysis changed. Please fix issue."
exit 1
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
if [ -f $BASE_DIR/config ] ; then
. $BASE_DIR/config
else
echo "Missing configuration"
exit 1
fi
if [ ! -f $UBM_VISUALIZATION ] ; then
echo "Missing user behavior visualization"
exit 1
fi
if [ ! -x $ANALYSIS ] ; then
echo "Missing analysis cli"
exit 1
fi
if [ ! -d $DATA_DIR ] ; then
echo "Data directory missing"
exit 1
fi
if [ ! -d $PCM_DIR ] ; then
echo "PCM directory missing"
exit 1
fi
## startup visualization
echo "------------------------"
echo "Build and start UBM service"
echo "------------------------"
docker-compose -f $UBM_VISUALIZATION build
docker-compose -f $UBM_VISUALIZATION up >& $BASE/docker-compose.log &
# deterime frontend IP address
CID_FRONTEND=`docker ps | grep code_frontend | awk '{ print $1 }'`
HOST_FRONTEND=`docker inspect $CID_FRONTEND | grep IPAddress | tail -1 | sed 's/.*:\ "\(.*\)",/\1/g'`
# deterime logic IP address
CID_LOGIC=`docker ps | grep code_logic | awk '{ print $1 }'`
HOST_LOGIC=`docker inspect $CID_LOGIC | grep IPAddress | tail -1 | sed 's/.*:\ "\(.*\)",/\1/g'`
URL_FRONTEND="http://$HOST_FRONTEND:3000/"
URL_LOGIC="http://$HOST_LOGIC:8080/ubm-backend/v1/"
## wait until service is available
echo "------------------------"
echo "Wait for service"
echo "------------------------"
while ! curl $URL_FRONTEND ; do
echo "wait frontend"
sleep 10
CID_FRONTEND=`docker ps | grep code_frontend | awk '{ print $1 }'`
HOST_FRONTEND=`docker inspect $CID_FRONTEND | grep IPAddress | tail -1 | sed 's/.*:\ "\(.*\)",/\1/g'`
URL_FRONTEND="http://$HOST_FRONTEND:3000/"
done
while ! curl $URL_LOGIC ; do
echo "wait for logic $CID_LOGIC"
sleep 10
CID_LOGIC=`docker ps | grep code_logic | awk '{ print $1 }'`
HOST_LOGIC=`docker inspect $CID_LOGIC | grep IPAddress | tail -1 | sed 's/.*:\ "\(.*\)",/\1/g'`
URL_LOGIC="http://$HOST_LOGIC:8080/ubm-backend/v1"
done
echo "Both web services are up. Press return to contiune"
# run analysis
echo "------------------------"
echo "Run analysis"
echo "------------------------"
$ANALYSIS -i "$DATA" -p "$PCM" -t 1 -v 4 -u "$URL_LOGIC"
echo "Analysis complete. Press return to contiune"
# stop setup
echo "------------------------"
echo "Terminate"
echo "------------------------"
docker-compose -f $UBM_VISUALIZATION down
# end