alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Alex Shatov | a5bfd6a | 2017-09-15 14:03:13 -0400 | [diff] [blame^] | 3 | # ============LICENSE_START======================================================= |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 4 | # org.onap.dcae |
| 5 | # ================================================================================ |
| 6 | # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. |
| 7 | # ================================================================================ |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # ============LICENSE_END========================================================= |
| 20 | # |
| 21 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 22 | |
| 23 | mkdir -p logs |
| 24 | LOG_FILE=logs/policy_handler.log |
| 25 | echo "---------------------------------------------" >> ${LOG_FILE} 2>&1 |
| 26 | echo "/etc/hosts" | tee -a ${LOG_FILE} |
| 27 | cat /etc/hosts | tee -a ${LOG_FILE} |
| 28 | python -m policyhandler/policy_handler >> ${LOG_FILE} 2>&1 & |
| 29 | PID=$! |
| 30 | |
| 31 | echo "running policy_handler as" ${PID} "log" ${LOG_FILE} | tee -a ${LOG_FILE} |
| 32 | function finish { |
| 33 | echo "killing policy_handler ${PID}" $(date +%Y_%m%d-%H:%M:%S.%N) | tee -a ${LOG_FILE} |
| 34 | kill -9 ${PID} |
| 35 | echo "killed policy_handler ${PID}" $(date +%Y_%m%d-%H:%M:%S.%N) | tee -a ${LOG_FILE} |
| 36 | } |
| 37 | trap finish SIGHUP SIGINT SIGTERM |
| 38 | |
| 39 | wait ${PID} |
| 40 | echo "---------------------------------------------" >> ${LOG_FILE} 2>&1 |
| 41 | mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S) |