博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux java -jar startup.sh
阅读量:4921 次
发布时间:2019-06-11

本文共 3891 字,大约阅读时间需要 12 分钟。

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

你可能感兴趣的文章
Maven Nexus
查看>>
js 判断滚动条的滚动方向
查看>>
css,js文件后面加一个版本号
查看>>
webpack第一节(2)
查看>>
python之asyncio三种应用方法
查看>>
转:[Server] 在 Windows 上安裝 PHP 5.3 開發環境
查看>>
【IE6的疯狂之二】IE6中PNG Alpha透明(全集)
查看>>
第一个Shell脚本
查看>>
C++ 小笔记
查看>>
Mysql 语句优化
查看>>
例子:进度条
查看>>
包含单引号的sql
查看>>
HTML 基础 2
查看>>
Java 最常见 200+ 面试题全解析:面试必备(转载)
查看>>
LinkedList
查看>>
Spring框架下PropertyPlaceholderConfigurer类配置roperties文件
查看>>
[原创]独立模式安装Hive
查看>>
链表实现单链表创建、排序(升序)
查看>>
Spring旅程(一)为什么使用Spring
查看>>
centos安装桌面和远程连接
查看>>