blob: c63fceeb377a6dfc29d5ff5ad2c2c1ce03e11591 [file] [log] [blame]
ATT default cloud user17b1b972017-08-31 21:34:47 +00001#!/bin/bash
2
3umask 0022
4TZ=GMT0
5COMPONENT=dmaapbc
6APP_ROOT=/opt/app/$COMPONENT
7USER=root
8export TZ
9PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin
10export PATH
11CLASSPATH=`echo $APP_ROOT/etc $APP_ROOT/lib/*.jar | tr ' ' ':'`
12export CLASSPATH
13CONTAINER_CONFIG=/opt/app/config/conf
14MAIN=org.onap.dmaap.dbcapi.server.Main
15
16
dglFromAtt6d9409c2018-04-10 00:38:14 -040017
ATT default cloud user17b1b972017-08-31 21:34:47 +000018pids() {
dglFromAtt24e34482018-03-21 08:28:10 -040019 set -x
ATT default cloud user17b1b972017-08-31 21:34:47 +000020 ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//'
dglFromAtt24e34482018-03-21 08:28:10 -040021 set +x
ATT default cloud user17b1b972017-08-31 21:34:47 +000022}
23
24config() {
25 set -x
26 if [ ! -d $APP_ROOT ]
27 then
28 echo "Expected app root directory $APP_ROOT does not exist"
29 exit 1
30 fi
31 if [ ! -f $CONTAINER_CONFIG ]
32 then
33 echo "Expected env file $CONTAINER_CONFIG not found"
34 exit 1
35 fi
36 cd $APP_ROOT
37 source $CONTAINER_CONFIG
dglFromAtt6d9409c2018-04-10 00:38:14 -040038
39 if [ "$DMAAPBC_WAIT_TO_EXIT" != "Y" ]
40 then
41 echo "Creating $APP_ROOT/ok_to_exit so no waiting..."
42 > $APP_ROOT/ok_to_exit
43 else
44 echo "Not creating $APP_ROOT/ok_to_exit"
45 fi
dglFromAttccb31a52018-03-03 12:00:41 -050046 # comment out till certs are available
47 #if [ ! -f $APP_ROOT/misc/cert-client-init.sh ]
48 #then
49 # echo "Did not find $APP_ROOT/misc/cert-client-init.sh to append to truststore"
50 # exit 1
51 #fi
52 #$APP_ROOT/misc/cert-client-init.sh
ATT default cloud user17b1b972017-08-31 21:34:47 +000053 . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties
54 . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties
55 set +x
56}
57
58start() {
59 set -x
60 ID=`id -n -u`
61 GRP=`id -n -g`
62 if [ "$ID" != "$USER" ]
63 then
64 echo $COMPONENT must be started as user $USER not $ID
65 exit 1
66 fi
67 if [ "$GRP" != "$USER" ]
68 then
69 echo $COMPONENT must be started as group $USER not $GRP
70 exit 1
71 fi
72 cd $APP_ROOT
73
74# disable until we use certs
75# if etc/havecert
76# then
77 echo >/dev/null
78# else
79# echo No certificate file available. Cannot start
80# exit 0
81# fi
82 PIDS=`pids`
83 if [ "$PIDS" != "" ]
84 then
85 echo $COMPONENT already running
86 exit 0
87 fi
88 rm -f $APP_ROOT/etc/SHUTDOWN
89
90 # JVM flags
91#old line from Dockerfile...keep for reference only
dglFromAttaac024c2018-04-10 05:33:06 -040092 FLAGS="-cp etc:lib/* -Dlog4j.configuration=etc/log4j.properties -Ddmaapbc.properties=etc/dmaapbc.properties -Dlogback.configurationFile=etc/logback.xml -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
dglFromAtt24e34482018-03-21 08:28:10 -040093 #nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 &
94 nohup java $FLAGS $MAIN </dev/null &
ATT default cloud user17b1b972017-08-31 21:34:47 +000095 sleep 5
96 PIDS=`pids`
ATT default cloud user17b1b972017-08-31 21:34:47 +000097 set +x
98}
99
100stop() {
101 ID=`id -n -u`
102 GRP=`id -n -g`
103 if [ "$ID" != "$USER" ]
104 then
105 echo $COMPONENT must be stopped as user $USER not $ID
106 exit 1
107 fi
108 if [ "$GRP" != "$USER" ]
109 then
110 echo $COMPONENT must be stopped as group $USER not $GRP
111 exit 1
112 fi
113 touch $APP_ROOT/etc/SHUTDOWN
114 PIDS=`pids`
115 if [ "$PIDS" != "" ]
116 then
117 sleep 5
118 kill -9 $PIDS
119 sleep 5
120 echo $COMPONENT stopped
121 else
122 echo $COMPONENT not running
123 fi
124}
125
126status() {
127 PIDS=`pids`
128 if [ "$PIDS" != "" ]
129 then
130 echo $COMPONENT running
131 else
132 echo $COMPONENT not running
133 fi
134}
135
136set -x
137case "$1" in
138'deploy')
139 config
140 start
141 wait
142 ;;
143'start')
144 start
145 ;;
146'stop')
147 stop
148 ;;
149'restart')
150 stop
151 sleep 20
152 start
153 ;;
154'status')
155 status
156 ;;
157*)
158 echo "Usage: $0 { start | stop | restart }"
159 exit 1
160 ;;
161esac
dglFromAtt24e34482018-03-21 08:28:10 -0400162 ls -l $APP_ROOT/logs/EELF
163 echo "------------ tail -100 error.log ---------------"
164 tail -100 $APP_ROOT/logs/EELF/error.log
165 echo "------------ tail -100 server.log ---------------"
166 tail -100 $APP_ROOT/logs/EELF/server.log
167 echo "------------ tail -100 application.log ---------------"
168 tail -100 $APP_ROOT/logs/EELF/application.log
dglFromAtt6d9409c2018-04-10 00:38:14 -0400169
170 echo "Check $APP_ROOT/ok_to_exit"
171 while [ ! -f $APP_ROOT/ok_to_exit ]
172 do
173 echo "$APP_ROOT/ok_to_exit does not exist. Sticking around for debugging..."
174 sleep 10
175 done
ATT default cloud user17b1b972017-08-31 21:34:47 +0000176exit 0