Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START======================================================= |
| 4 | # ONAP CLAMP |
| 5 | # ================================================================================ |
| 6 | # Copyright (C) 2017 AT&T Intellectual Property. All rights |
| 7 | # reserved. |
| 8 | # ================================================================================ |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END============================================ |
| 21 | # =================================================================== |
| 22 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 23 | # |
| 24 | |
Gary Wu | 13111e9 | 2018-09-27 11:31:33 -0700 | [diff] [blame] | 25 | echo "This is ${WORKSPACE}/scripts/vvp/start_vvp_containers.sh" |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 26 | |
| 27 | export IP=$HOST_IP |
| 28 | export PREFIX='nexus3.onap.org:10001/openecomp/vvp' |
| 29 | export RELEASE='latest' |
| 30 | |
| 31 | #start Engagement Manager pod: |
| 32 | docker run \ |
| 33 | --detach \ |
| 34 | --entrypoint="" \ |
| 35 | --name vvp-engagementmgr \ |
| 36 | --env-file ${WORKSPACE}/data/environments/vvp_env.list \ |
| 37 | --log-driver=json-file \ |
| 38 | --log-opt max-size=100m \ |
| 39 | --log-opt max-file=10 \ |
| 40 | --ulimit memlock=-1:-1 \ |
| 41 | --memory 4g \ |
| 42 | --memory-swap=4g \ |
| 43 | --ulimit nofile=4096:100000 \ |
| 44 | --volume /etc/localtime:/etc/localtime:ro \ |
| 45 | --volume /opt/configmaps/settings:/opt/configmaps/settings/ \ |
| 46 | --publish 9090:80 ${PREFIX}/engagementmgr:${RELEASE} |
| 47 | |
| 48 | docker cp /opt/configmaps/settings/uwsgi.ini vvp-engagementmgr:/srv/vvp/settings/ |
| 49 | |
| 50 | echo "please wait while Engagement Manager is starting..." |
| 51 | echo "" |
| 52 | c=60 # seconds to wait |
| 53 | REWRITE="\e[25D\e[1A\e[K" |
| 54 | while [ $c -gt 0 ]; do |
| 55 | c=$((c-1)) |
| 56 | sleep 1 |
| 57 | echo -e "${REWRITE}$c" |
| 58 | done |
| 59 | echo -e "" |
| 60 | |
| 61 | #run migration again: |
| 62 | docker exec -d vvp-engagementmgr sh -c "python3 /srv/manage.py migrate" |
| 63 | |
| 64 | #run initial populate db again: |
| 65 | docker exec -d vvp-engagementmgr sh -c "python3 /srv/manage.py initial_populate_db" |
| 66 | |
| 67 | |
| 68 | echo "Will copy the generated DB sqlite3 file into the application directory in 30 seconds..." |
| 69 | sleep 30 |
| 70 | #copy the generated DB sqlite3 file into the application directory: |
| 71 | docker exec -d vvp-engagementmgr sh -c "cp emdb.db /srv/emdb.db -f" |
| 72 | |
| 73 | TIME_OUT=600 |
| 74 | INTERVAL=5 |
| 75 | TIME=0 |
| 76 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 77 | response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:9090/vvp/v1/engmgr/vendors); echo $response |
| 78 | |
| 79 | if [ "$response" == "200" ]; then |
| 80 | echo VVP-Engagement-Manager well started in $TIME seconds |
| 81 | break; |
| 82 | fi |
| 83 | |
| 84 | echo Sleep: $INTERVAL seconds before testing if VVP-Engagement-Manager is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 85 | sleep $INTERVAL |
| 86 | TIME=$(($TIME+$INTERVAL)) |
| 87 | done |
| 88 | |
| 89 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 90 | echo TIME OUT: Docker containers not started in $TIME_OUT seconds... Could cause problems for tests... |
| 91 | else |
| 92 | echo "Done starting vvp containers!" |
| 93 | fi |