blob: 8fa23a2023536de0e22b52c016d7bec399ccdd2a [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_sh9d980ce2017-08-23 17:30:56 -04004# 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
23mkdir -p logs
24LOG_FILE=logs/policy_handler.log
25echo "---------------------------------------------" >> ${LOG_FILE} 2>&1
26echo "/etc/hosts" | tee -a ${LOG_FILE}
27cat /etc/hosts | tee -a ${LOG_FILE}
28python -m policyhandler/policy_handler >> ${LOG_FILE} 2>&1 &
29PID=$!
30
31echo "running policy_handler as" ${PID} "log" ${LOG_FILE} | tee -a ${LOG_FILE}
32function 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}
37trap finish SIGHUP SIGINT SIGTERM
38
39wait ${PID}
40echo "---------------------------------------------" >> ${LOG_FILE} 2>&1
41mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S)