blob: a7ddde453c807f3fbf991edce233011085a6c93f [file] [log] [blame]
alex_sh9d980ce2017-08-23 17:30:56 -04001#!/bin/bash
2
Alex Shatova5bfd6a2017-09-15 14:03:13 -04003# ============LICENSE_START=======================================================
Lusheng Ji967cc9a2018-02-12 10:45:42 -05004# Copyright (c) 2017-2018 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#
19# ECOMP is a trademark and service mark of AT&T Intellectual Property.
20
21mkdir -p logs
22LOG_FILE=logs/policy_handler.log
Alex Shatovd444b322018-06-21 09:19:07 -040023exec &>> >(tee -a ${LOG_FILE})
24echo "---------------------------------------------"
25STARTED=$(date +%Y-%m-%d_%T.%N)
26echo "${STARTED}: running ${BASH_SOURCE[0]}"
27echo "APP_VER =" $(python setup.py --version)
28(uname -a; echo "/etc/hosts"; cat /etc/hosts; pwd)
Alex Shatovc9ec2312018-06-14 12:06:42 -040029
Alex Shatovd444b322018-06-21 09:19:07 -040030python -m policyhandler &
alex_sh9d980ce2017-08-23 17:30:56 -040031PID=$!
32
alex_sh9d980ce2017-08-23 17:30:56 -040033function finish {
Alex Shatovd444b322018-06-21 09:19:07 -040034 echo "killing policy_handler ${PID}" $(date +%Y_%m%d-%T.%N)
alex_sh9d980ce2017-08-23 17:30:56 -040035 kill -9 ${PID}
Alex Shatovd444b322018-06-21 09:19:07 -040036 echo "killed policy_handler ${PID}" $(date +%Y_%m%d-%T.%N)
alex_sh9d980ce2017-08-23 17:30:56 -040037}
38trap finish SIGHUP SIGINT SIGTERM
39
Alex Shatovd444b322018-06-21 09:19:07 -040040echo "running policy_handler as ${PID} logs to ${LOG_FILE}"
41(free -h; df -h; ps afxvw; ss -aepi)
Alex Shatov51052582018-05-18 15:13:40 -040042
alex_sh9d980ce2017-08-23 17:30:56 -040043wait ${PID}
Alex Shatovd444b322018-06-21 09:19:07 -040044exec &>> >(tee -a ${LOG_FILE})
45echo "---------------------------------------------"
46echo "$(date +%Y-%m-%d_%T.%N): exit ${BASH_SOURCE[0]} that was started on ${STARTED}"
47
alex_sh9d980ce2017-08-23 17:30:56 -040048mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S)