forked from imesh/wso2-apim-conf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·112 lines (90 loc) · 3.73 KB
/
setup.sh
File metadata and controls
executable file
·112 lines (90 loc) · 3.73 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -e
host="localhost"
mysql_port1=3306
mysql_port2=3307
connector_jar="mysql-connector-java-5.1.36-bin.jar"
apim_instance_count=2
synapse_folder_path="repository/deployment/server/synapse-configs"
script_path=`pwd`
function check_container_exists() {
name=$1
if [ "$(docker ps -q -f name=${name})" ]; then
echo "Error: Container ${name} exist! Run the clean.sh and try again."
exit 1;
fi
}
function wait_for_port() {
port=$1
while ! echo exit | (nc localhost ${port} > /dev/null); do sleep 2; done
}
echo "Starting API-M database container..."
check_container_exists "wso2-apim-db"
docker run --name "wso2-apim-db" -p ${mysql_port1}:3306 -e MYSQL_ROOT_PASSWORD=mysql \
-e MYSQL_USER=mysql \
-e MYSQL_PASSWORD=mysql \
-e MYSQL_DATABASE=wso2apim_db -d mysql:5.5
echo "Starting WSO2 API-M Analytics database container..."
check_container_exists "wso2-apim-analytics-db"
docker run --name "wso2-apim-analytics-db" -p ${mysql_port2}:3306 -e MYSQL_ROOT_PASSWORD=mysql \
-e MYSQL_USER=mysql \
-e MYSQL_PASSWORD=mysql \
-e MYSQL_DATABASE=wso2apim_analytics_db -d mysql:5.5
echo "Extracting API-M distribution..."
unzip dist/wso2am-2.1.0.zip
if (( apim_instance_count == 1 )); then
echo "Creating API-M node 1..."
mv "wso2am-2.1.0" "wso2am-2.1.0-1"
else
echo "Creating API-M node1..."
cp -r "wso2am-2.1.0" "wso2am-2.1.0-1"
echo "Creating API-M node2..."
mv "wso2am-2.1.0" "wso2am-2.1.0-2"
echo "Creating symlinks for API synchronization..."
rm -rf wso2am-2.1.0-1/${synapse_folder_path}
rm -rf wso2am-2.1.0-2/${synapse_folder_path}
ln -sfnv ${script_path}/volumes/apim-gateway/synapse-configs ${script_path}/wso2am-2.1.0-1/${synapse_folder_path}
ln -sfnv ${script_path}/volumes/apim-gateway/synapse-configs ${script_path}/wso2am-2.1.0-2/${synapse_folder_path}
fi
echo "Extracting API-M analytics distribution..."
unzip dist/wso2am-analytics-2.1.0.zip
echo "Copying MySQL connector JAR file..."
cp dist/${connector_jar} wso2am-2.1.0-1/repository/components/lib/
if (( apim_instance_count == 2 )); then
cp dist/${connector_jar} wso2am-2.1.0-2/repository/components/lib/
fi
cp dist/${connector_jar} wso2am-analytics-2.1.0/repository/components/lib/
echo "Copying API-M node 1 configurations..."
cp -r conf/wso2am-2.1.0-1/ wso2am-2.1.0-1/
if (( apim_instance_count == 2 )); then
echo "Copying API-M node 2 configurations..."
cp -r conf/wso2am-2.1.0-1/ wso2am-2.1.0-2/
cp -r conf/wso2am-2.1.0-2/ wso2am-2.1.0-2/
fi
echo "Copying API-M analytics configurations..."
cp -r conf/wso2am-analytics-2.1.0/ wso2am-analytics-2.1.0/
echo "Waiting API-M database to start on ${host}:${mysql_port1}"
wait_for_port ${mysql_port1}
echo "API-M database became ready!"
echo "Waiting API-M analytics database to start on ${host}:${mysql_port2}"
wait_for_port ${mysql_port2}
echo "API-M Analytics database became ready!"
echo "Starting WSO2 API-M analytics node..."
sh "wso2am-analytics-2.1.0/bin/wso2server.sh" -Dsetup start
wait_for_port 9444
echo "WSO2 API-M analytics node started!"
echo "Starting WSO2 API-M node 1..."
sh wso2am-2.1.0-1/bin/wso2server.sh -Dsetup start
wait_for_port 9443
echo "WSO2 API-M node 1 started!"
if (( apim_instance_count == 2 )); then
echo "Starting WSO2 API-M node 2..."
sh wso2am-2.1.0-2/bin/wso2server.sh -Dsetup start
wait_for_port 9445
echo "WSO2 API-M node 2 started!"
fi
echo "Checking for errors..."
cat wso2am-2.1.0-1/repository/logs/wso2carbon.log | grep ERROR
cat wso2am-2.1.0-2/repository/logs/wso2carbon.log | grep ERROR
cat wso2am-analytics-2.1.0/repository/logs/wso2carbon.log | grep ERROR
echo "Setup completed!"