-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathlooker
executable file
·145 lines (128 loc) · 4.14 KB
/
looker
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
cd $HOME/looker
# set your java memory- there should be over 1.5G of system memory
# left to run the OS
MEM=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
JM=`expr $MEM \* 6 / 10`
JAVAMEM="${JM}k"
METAMEM="800m"
# Extra Java startup args and Looker startup args. These can also be set in
# a file named lookerstart.cfg
JMXARGS="-Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.port=9910 -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.ssl=false -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.local.only=false -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.authenticate=true -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.access.file=${HOME}/.lookerjmx/jmxremote.access -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.password.file=${HOME}/.lookerjmx/jmxremote.password"
# to set up JMX monitoring, add JMXARGS to JAVAARGS
JAVAARGS=""
LOOKERARGS="--force-gcm-encryption"
# check for a lookerstart.cfg file to set JAVAARGS and LOOKERARGS
if [ -r ./lookerstart.cfg ]; then
. ./lookerstart.cfg
fi
# check if --no-ssl is specified in LOOKERARGS and set protocol accordingly
PROTOCOL=""
echo "${LOOKERARGS}" | grep -q "\-\-no\-ssl"
if [ $? -eq 0 ]
then
PROTOCOL='http'
else
PROTOCOL='https'
fi
LOOKERPORT=${LOOKERPORT:-"9999"}
start() {
if [ -e .deploying ]; then
echo "Startup suppressed: ${PWD}/.deploying file exists. Remove .deploying file to allow startup"
exit 1
fi
LOCKFILE=.starting
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "Startup suppressed: ${LOCKFILE} contains running pid, startup script is already running"
exit 1
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
fixcrypt
java \
-XX:+UseG1GC -XX:MaxGCPauseMillis=2000 -XX:MaxMetaspaceSize=$METAMEM \
-Xms$JAVAMEM -Xmx$JAVAMEM \
-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \
-Xloggc:/tmp/gc.log ${JAVAARGS} \
-jar looker.jar start ${LOOKERARGS}
if [ -x ./tunnel ]; then
./tunnel start
fi
rm -f ${LOCKFILE}
}
stop() {
pid=`cat .tmp/looker.pid`
if [ -f .status_server_token ] && [ -x /usr/bin/curl ]; then
state="running"
token=`cat .status_server_token`
request="control/stop?token=${token}"
timeout 20 curl -m 10 -ks ${PROTOCOL}://127.0.0.1:${LOOKERPORT}/${request} > /dev/null 2>&1
ECODE=$?
[ $ECODE -eq 7 ] && state="stopped"
if [ $ECODE -gt 7 ] ; then
kill $pid
fi
for i in {1..30}; do
timeout 20 curl -m 5 -ks ${PROTOCOL}://127.0.0.1:${LOOKERPORT}/alive > /dev/null 2>&1
ECODE=$?
if [ $ECODE -eq 7 ]; then
state="stopped"
break
fi
if [ $ECODE -gt 7 ] ; then
kill -9 $pid
fi
sleep 1
done
if [ "${state}" = "running" ]; then
echo "Force Stop Looker Web Application"
kill $pid
kill -0 $pid && kill -9 $pid
fi
else
timeout 20 java -jar looker.jar stop
if [ $? -ne 0 ]; then
kill -9 $pid
fi
fi
}
fixcrypt() {
CRYPTEXIST=`/sbin/ldconfig -p | grep -c '\slibcrypt.so\s'`
if [ $CRYPTEXIST -eq 0 ]; then
if [ ! -d .tmp ]; then
mkdir .tmp
fi
CRYPTLN=`/sbin/ldconfig -p | grep '\slibcrypt\.so\.[[:digit:]]' | awk '{print $(NF)}'`
ln -s -f $CRYPTLN `pwd`/.tmp/libcrypt.so
export LD_LIBRARY_PATH=`pwd`/.tmp/:$LD_LIBRARY_PATH
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo "Restarting Looker Web Application" "looker"
stop
sleep 3
start
;;
status)
curl -ks ${PROTOCOL}://127.0.0.1:${LOOKERPORT}/alive > /dev/null 2>&1
if [ $? -eq 7 ]; then
echo "Status:Looker Web Application stopped"
exit 7
else
echo "Status:Looker Web Application running"
exit 0
fi
;;
*)
java -jar looker.jar $*
;;
esac
exit 0