blob: 8055bead0a510d54f254cd4f16cd803bade07f17 [file] [log] [blame]
alex_sh9d980ce2017-08-23 17:30:56 -04001#!/bin/bash
2
Alex Shatova5bfd6a2017-09-15 14:03:13 -04003# ============LICENSE_START=======================================================
Alex Shatov9a4d3c52019-04-01 11:32:06 -04004# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
alex_sh9d980ce2017-08-23 17:30:56 -04005# ================================================================================
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_sh9d980ce2017-08-23 17:30:56 -040019
20mkdir -p logs
21LOG_FILE=logs/policy_handler.log
Alex Shatovd444b322018-06-21 09:19:07 -040022exec &>> >(tee -a ${LOG_FILE})
23echo "---------------------------------------------"
24STARTED=$(date +%Y-%m-%d_%T.%N)
25echo "${STARTED}: running ${BASH_SOURCE[0]}"
Alex Shatov9a4d3c52019-04-01 11:32:06 -040026echo "APP_VER="$(python setup.py --version)
27echo "HOSTNAME=${HOSTNAME}"
28echo "CONSUL_URL=${CONSUL_URL}"
29echo "PDP_API_VERSION=${PDP_API_VERSION}"
Alex Shatov209f8232018-09-20 15:15:45 -040030(pwd; uname -a; echo "/etc/hosts"; cat /etc/hosts; openssl version -a)
Alex Shatovc9ec2312018-06-14 12:06:42 -040031
Alex Shatovd444b322018-06-21 09:19:07 -040032python -m policyhandler &
alex_sh9d980ce2017-08-23 17:30:56 -040033PID=$!
34
alex_sh9d980ce2017-08-23 17:30:56 -040035function finish {
Alex Shatovd444b322018-06-21 09:19:07 -040036 echo "killing policy_handler ${PID}" $(date +%Y_%m%d-%T.%N)
alex_sh9d980ce2017-08-23 17:30:56 -040037 kill -9 ${PID}
Alex Shatovd444b322018-06-21 09:19:07 -040038 echo "killed policy_handler ${PID}" $(date +%Y_%m%d-%T.%N)
alex_sh9d980ce2017-08-23 17:30:56 -040039}
40trap finish SIGHUP SIGINT SIGTERM
41
Alex Shatovd444b322018-06-21 09:19:07 -040042echo "running policy_handler as ${PID} logs to ${LOG_FILE}"
43(free -h; df -h; ps afxvw; ss -aepi)
Alex Shatov51052582018-05-18 15:13:40 -040044
alex_sh9d980ce2017-08-23 17:30:56 -040045wait ${PID}
Alex Shatovd444b322018-06-21 09:19:07 -040046exec &>> >(tee -a ${LOG_FILE})
47echo "---------------------------------------------"
48echo "$(date +%Y-%m-%d_%T.%N): exit ${BASH_SOURCE[0]} that was started on ${STARTED}"
49
alex_sh9d980ce2017-08-23 17:30:56 -040050mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S)