ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | umask 0022 |
| 4 | TZ=GMT0 |
| 5 | COMPONENT=dmaapbc |
| 6 | APP_ROOT=/opt/app/$COMPONENT |
| 7 | USER=root |
| 8 | export TZ |
| 9 | PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin |
| 10 | export PATH |
| 11 | CLASSPATH=`echo $APP_ROOT/etc $APP_ROOT/lib/*.jar | tr ' ' ':'` |
| 12 | export CLASSPATH |
| 13 | CONTAINER_CONFIG=/opt/app/config/conf |
| 14 | MAIN=org.onap.dmaap.dbcapi.server.Main |
| 15 | |
| 16 | |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 17 | |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 18 | pids() { |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 19 | set -x |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 20 | ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//' |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 21 | set +x |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | config() { |
| 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 |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 38 | |
| 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 |
dglFromAtt | ccb31a5 | 2018-03-03 12:00:41 -0500 | [diff] [blame] | 46 | # 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 user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 53 | . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties |
| 54 | . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties |
| 55 | set +x |
| 56 | } |
| 57 | |
| 58 | start() { |
| 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 |
dglFromAtt | aac024c | 2018-04-10 05:33:06 -0400 | [diff] [blame^] | 92 | 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" |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 93 | #nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 & |
| 94 | nohup java $FLAGS $MAIN </dev/null & |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 95 | sleep 5 |
| 96 | PIDS=`pids` |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 97 | set +x |
| 98 | } |
| 99 | |
| 100 | stop() { |
| 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 | |
| 126 | status() { |
| 127 | PIDS=`pids` |
| 128 | if [ "$PIDS" != "" ] |
| 129 | then |
| 130 | echo $COMPONENT running |
| 131 | else |
| 132 | echo $COMPONENT not running |
| 133 | fi |
| 134 | } |
| 135 | |
| 136 | set -x |
| 137 | case "$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 | ;; |
| 161 | esac |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 162 | 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 |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 169 | |
| 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 user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 176 | exit 0 |