-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-appmanager.sh
46 lines (44 loc) · 1.36 KB
/
start-appmanager.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
#!/bin/bash
#npm install express --save
#npm install cors --save
#npm install body-parser --save
#npm install jwt-simple --save
#npm install moment --save
#npm install express-fileupload --save
#npm install https --save
#npm install http --save
#GLOBAL VARIABLES
app=`basename $0`;
SERVER_DIR=~/phantom_servers/;
BASE_DIR=`dirname $0`;
cd ${BASE_DIR};
BASE_DIR=`pwd`;
TMP_DIR=${SERVER_DIR}/tmp;
DIST_DIR=${SERVER_DIR}/dist;
appmanager_port=8500;
cd server_code;
# IF THE SERVER WAS RUNNING, WE STOP IT BEFORE START A NEW INSTANCE
bash ../stop-appmanager.sh
# START A NEW INSTACE OF THE APPMANAGER
if [ ! -d node_modules ]; then
ln -s ~/phantom_servers/node_modules node_modules;
fi;
${DIST_DIR}/nodejs/bin/node appmanager_app.js &
pid=$!;
echo "pid if the server is ${pid}";
echo ${pid} > ${TMP_DIR}/appmanager.pid;
sleep 1;
# CHECK IF THE APP MANAGER IS RUNNING
let "j=0";
HTTP_STATUS=$(curl -s -w %{http_code} http://localhost:${appmanager_port})
while [[ ${HTTP_STATUS} != *"200"* ]] && [ ${j} -lt 30 ] ; do
echo -n "$j. "; let "j += 1 "; sleep 1;
HTTP_STATUS=$(curl -s -w %{http_code} http://localhost:${appmanager_port})
done;
if [ ${j} -ge 30 ]; then
echo "[ERROR]: APP MANAGER doesn't started.";
exit;
fi;
echo ; #Here, we will show the current version of the running PHANTOM APP MANAGER
curl http://localhost:${appmanager_port};
echo -e "\n\n";