-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopApi.sh
executable file
·42 lines (35 loc) · 980 Bytes
/
stopApi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# stop the API
# archive the ${LOG_FILE}
#
if [ -f ./Configuration ]
then
. ./Configuration
else
echo "Configuration file is missing in mgd_java_api"
exit 1
fi
echo "Stopping Java API"
if [ -f ${MGI_LIVE}/mgd_java_api.pid ]
then
PID=`cat ${MGI_LIVE}/mgd_java_api.pid`
KILLPID=`pgrep -u ${USER} -f "target/mgd_java_api-runner" | grep ${PID}`
if [ ! -z ${KILLPID} ]
then
printf "Killing process with pid=${KILLPID}\n"
kill -HUP ${KILLPID}
else
printf "No process with pid=${KILLPID}\n"
fi
rm -rf ${MGI_LIVE}/mgd_java_api.pid
else
printf "No pid file.\n"
fi
# some time for log to flush before archiving
sleep 5
echo "Timestamp and save log file"
timestamp=`date '+%Y%m%d.%H%M'`
cp -r ${LOG_FILE} ${LOG_FILE}.${timestamp}
echo "Remove old archived log files : older than 360 days"
find ${LOG_DIR}/* -type f -mtime +360 -exec rm -rf {} \;