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 Shatov | 9a4d3c5 | 2019-04-01 11:32:06 -0400 | [diff] [blame] | 4 | # Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 5 | # ================================================================================ |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # ============LICENSE_END========================================================= |
| 18 | # |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 19 | |
| 20 | mkdir -p logs |
| 21 | LOG_FILE=logs/policy_handler.log |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 22 | exec &>> >(tee -a ${LOG_FILE}) |
| 23 | echo "---------------------------------------------" |
| 24 | STARTED=$(date +%Y-%m-%d_%T.%N) |
| 25 | echo "${STARTED}: running ${BASH_SOURCE[0]}" |
Alex Shatov | 9a4d3c5 | 2019-04-01 11:32:06 -0400 | [diff] [blame] | 26 | echo "APP_VER="$(python setup.py --version) |
| 27 | echo "HOSTNAME=${HOSTNAME}" |
| 28 | echo "CONSUL_URL=${CONSUL_URL}" |
| 29 | echo "PDP_API_VERSION=${PDP_API_VERSION}" |
Alex Shatov | 209f823 | 2018-09-20 15:15:45 -0400 | [diff] [blame] | 30 | (pwd; uname -a; echo "/etc/hosts"; cat /etc/hosts; openssl version -a) |
Alex Shatov | c9ec231 | 2018-06-14 12:06:42 -0400 | [diff] [blame] | 31 | |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 32 | python -m policyhandler & |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 33 | PID=$! |
| 34 | |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 35 | function finish { |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 36 | echo "killing policy_handler ${PID}" $(date +%Y_%m%d-%T.%N) |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 37 | kill -9 ${PID} |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 38 | echo "killed policy_handler ${PID}" $(date +%Y_%m%d-%T.%N) |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 39 | } |
| 40 | trap finish SIGHUP SIGINT SIGTERM |
| 41 | |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 42 | echo "running policy_handler as ${PID} logs to ${LOG_FILE}" |
| 43 | (free -h; df -h; ps afxvw; ss -aepi) |
Alex Shatov | 5105258 | 2018-05-18 15:13:40 -0400 | [diff] [blame] | 44 | |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 45 | wait ${PID} |
Alex Shatov | d444b32 | 2018-06-21 09:19:07 -0400 | [diff] [blame] | 46 | exec &>> >(tee -a ${LOG_FILE}) |
| 47 | echo "---------------------------------------------" |
| 48 | echo "$(date +%Y-%m-%d_%T.%N): exit ${BASH_SOURCE[0]} that was started on ${STARTED}" |
| 49 | |
Schmalzried, Terry (ts862m) | 05f475f | 2019-11-13 16:47:45 -0500 | [diff] [blame] | 50 | rm -f ${LOG_FILE}.2[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9] |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 51 | mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S) |