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======================================================= |
Lusheng Ji | 967cc9a | 2018-02-12 10:45:42 -0500 | [diff] [blame] | 4 | # Copyright (c) 2017-2018 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 | # |
| 19 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 20 | |
| 21 | mkdir -p logs |
| 22 | LOG_FILE=logs/policy_handler.log |
| 23 | echo "---------------------------------------------" >> ${LOG_FILE} 2>&1 |
Alex Shatov | c9ec231 | 2018-06-14 12:06:42 -0400 | [diff] [blame^] | 24 | echo "APP_VER =" $(python setup.py --version) | tee -a ${LOG_FILE} |
| 25 | uname -a | tee -a ${LOG_FILE} |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 26 | echo "/etc/hosts" | tee -a ${LOG_FILE} |
| 27 | cat /etc/hosts | tee -a ${LOG_FILE} |
Alex Shatov | c9ec231 | 2018-06-14 12:06:42 -0400 | [diff] [blame^] | 28 | pwd | tee -a ${LOG_FILE} |
| 29 | |
| 30 | python -m policyhandler >> ${LOG_FILE} 2>&1 & |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 31 | PID=$! |
| 32 | |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 33 | function finish { |
| 34 | echo "killing policy_handler ${PID}" $(date +%Y_%m%d-%H:%M:%S.%N) | tee -a ${LOG_FILE} |
| 35 | kill -9 ${PID} |
| 36 | echo "killed policy_handler ${PID}" $(date +%Y_%m%d-%H:%M:%S.%N) | tee -a ${LOG_FILE} |
| 37 | } |
| 38 | trap finish SIGHUP SIGINT SIGTERM |
| 39 | |
Alex Shatov | 5105258 | 2018-05-18 15:13:40 -0400 | [diff] [blame] | 40 | echo "running policy_handler as" ${PID} "log" ${LOG_FILE} | tee -a ${LOG_FILE} |
Alex Shatov | 5105258 | 2018-05-18 15:13:40 -0400 | [diff] [blame] | 41 | free -h | tee -a ${LOG_FILE} |
| 42 | df -h | tee -a ${LOG_FILE} |
| 43 | ps afxvw | tee -a ${LOG_FILE} |
| 44 | ss -aepi | tee -a ${LOG_FILE} |
| 45 | |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 46 | wait ${PID} |
| 47 | echo "---------------------------------------------" >> ${LOG_FILE} 2>&1 |
| 48 | mv ${LOG_FILE} ${LOG_FILE}.$(date +%Y-%m-%d_%H%M%S) |