linux java -jar startup.sh

set ff=unix
#!/bin/bash
a=`date +%Y%m%d`;#获取当前时间
start(){
echo "start project..."
if [[ ! -d ./pid/ ]];
then
mkdir -p pid;
fi;
if [[ ! -d ./serverLog/ ]];
then
mkdir -p serverLog;
fi;
#注意:必须有&让其后台执行,否则没有pid生成
java -Dfile.encoding=utf-8 -jar nelda-center.jar nelda-center > ./serverLog/{$a}_nelda-center.log &
echo $! > ./pid/nelda-center.pid # 将jar包启动对应的pid写入文件中,为停止时提供pid
java -Dfile.encoding=utf-8 -jar nelda-gate.jar nelda-gate > ./serverLog/{$a}_nelda-gate.log 2>&1 &
echo $! > ./pid/nelda-gate.pid
java -Dfile.encoding=utf-8 -jar nelda-auth.jar nelda-auth > ./serverLog/{$a}_nelda-auth.log 2>&1 &
echo $! > ./pid/nelda-auth.pid
java -Dfile.encoding=utf-8 -jar nelda-business.jar nelda-business > ./serverLog/{$a}_nelda-business.log 2>&1 &
echo $! > ./pid/nelda-business.pid
java -Dfile.encoding=utf-8 -jar nelda-admin.jar nelda-admin > ./serverLog/{$a}_nelda-admin.log 2>&1 &
echo $! > ./pid/nelda-admin.pid

echo "start project end..."
}

stop(){
echo "stop project..."
PID=$(cat ./pid/nelda-center.pid)
kill -9 $PID
PID=$(cat ./pid/nelda-gate.pid)
kill -9 $PID
PID=$(cat ./pid/nelda-auth.pid )
kill -9 $PID
PID=$(cat ./pid/nelda-business.pid)
kill -9 $PID
PID=$(cat ./pid/nelda-admin.pid)
kill -9 $PID
echo "stop project end..."
rm -rf ./pid
}
#停止指定的服务
stopAppoint(){
echo 'Stop the specified service'
echo 'stop nelda-center-------->1'
echo 'stop nelda-gate---------->2'
echo 'stop nelda-auth---------->3'
echo 'stop nelda-business------>4'
echo 'stop nelda-admin--------->5'
read aNum
case $aNum in
1) echo 'your choose nelda-center'
PID=$(cat ./pid/nelda-center.pid)
kill -9 $PID
rm -rf ./pid/nelda-center.pid
exit;
;;
2) echo 'your choose nelda-gate'
PID=$(cat ./pid/nelda-gate.pid)
kill -9 $PID
rm -rf ./pid/nelda-gate.pid
exit;
;;
3) echo 'your choose nelda-auth'
PID=$(cat ./pid/nelda-auth.pid)
kill -9 $PID
rm -rf ./pid/nelda-auth.pid
exit;
;;
4) echo 'your choose nelda-business'
PID=$(cat ./pid/nelda-business.pid)
kill -9 $PID
rm -rf ./pid/nelda-business.pid
exit;
;;
5) echo 'your choose nelda-admin'
PID=$(cat ./pid/nelda-admin.pid)
kill -9 $PID
rm -rf ./pid/nelda-admin.pid
exit;
;;
*) echo 'There are no numbers you enter'
exit 1
;;
esac

}

#启动指定的服务
startAppoint(){
echo 'Start the specified service'
echo 'Start nelda-center----------->1'
echo 'Start nelda-gate------------->2'
echo 'Start nelda-auth------------->3'
echo 'Start nelda-business--------->4'
echo 'Start nelda-admin------------>5'
if [[ ! -d ./pid/ ]];
then
mkdir -p pid;
fi;
read aNum
case $aNum in
1) echo 'your choose nelda-center'
#注意:必须有&让其后台执行,否则没有pid生成
java -jar nelda-center.jar nelda-center > ./serverLog/{$a}_nelda-center.log &
#将jar包启动对应的pid写入文件中,为停止时提供pid
echo $! > ./pid/nelda-center.pid
;;
2) echo 'your choose nelda-gate'
java -jar nelda-gate.jar nelda-gate> ./serverLog/{$a}_nelda-gate.log 2>&1 &
echo $! > ./pid/nelda-gate.pid
;;
3) echo 'your choose nelda-auth'
java -jar nelda-auth.jar > ./serverLog/{$a}_nelda-auth.log 2>&1 &
echo $! > ./pid/nelda-auth.pid
;;
4) echo 'your choose nelda-business'
java -jar nelda-business.jar > ./serverLog/{$a}_nelda-business.log 2>&1 &
echo $! > ./pid/nelda-business.pid
;;
5) echo 'your choose nelda-admin'
java -Dfile.encoding=utf-8 -jar nelda-admin.jar > ./serverLog/{$a}_nelda-admin.log 2>&1 &
echo $! > ./pid/nelda-admin.pid
;;
*) echo 'There are no numbers you enter'
exit 1
;;
esac
}

restart(){
stop
sleep 1
start
}

echo 'choose your number'
echo 'start all server----->1'
echo 'start appoint server----->2'
echo 'stop all server----->3'
echo 'stop appoint server----->4'
echo 'restart all server----->5'
read aNum
case $aNum in
1) echo 'your choose 1'
start;
exit;
;;
2) echo 'your choose 2'
startAppoint;
exit;
;;
3) echo 'your choose 3'
stop;
exit;
;;
4) echo 'your choose 4'
stopAppoint;
exit;
;;
5) echo 'your choose 5'
restart
exit;
;;
*) echo 'There are no numbers you enter'
exit 1
;;
esac

转载于:https://www.cnblogs.com/xzhg/p/8633225.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值