#!/bin/bash
date_str=`date +%Y%m%d`
dir=/java/backup
my_back_dir="$dir/$date_str"
export APP_PATH=/java/webapps
echo "[$(date +'%F %T')] >>> BACK UP APP."
if [ ! -d "$my_back_dir" ]; then
echo "Create Dir"
mkdir $my_back_dir
else
echo "Dir Exists"
fi
scp $APP_PATH/jinan-hospital-api-2.1.3.RELEASE.jar $my_back_dir/jinan-hospital-api-2.1.3.RELEASE.jar_$RANDOM
pidList=$(ps aux | grep /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar | grep -v grep | awk '{print $2}')
for pid in $pidList;do
kill -9 $pid
echo "[$(date +'%F %T')] >>> kill the precess [$pid] successfully."
done
echo "scp file start"
scp /java/publish_dir/jinan-hospital-api-2.1.3.RELEASE.jar $APP_PATH
echo "scp file end"
echo "start app"
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=test &
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=publish &
echo "start app end"