1 changed files with 80 additions and 0 deletions
@ -0,0 +1,80 @@ |
|||
#!/bin/bash |
|||
#set -x |
|||
set -e |
|||
|
|||
echoPrefix="\033[36m+" |
|||
echoSuffix="\033[0m" |
|||
|
|||
logPath=/data/logs/xxl-job/xxl-job.log |
|||
dirPath=/home/www/deploy/xxl-job/ |
|||
serverName=xxl_job_test |
|||
|
|||
cmd=$1 |
|||
profiles=${2:-"hwy-test"} |
|||
|
|||
#------------------------------------------------------------------- |
|||
JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx1g -Xms1g" |
|||
DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false" |
|||
JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai" |
|||
#------------------------------------------------------------------- |
|||
|
|||
startServer() { |
|||
pid=$1 |
|||
if [ -z $pid ];then |
|||
echo -e "$echoPrefix cd $dirPath $echoSuffix" |
|||
cd $dirPath |
|||
echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar bin/xxl-job-admin-mysql-2.3.0.jar --spring.config.location=conf/ --spring.profiles.active=global,$profiles --server.port=8001 >>/dev/null 2>&1 & $echoSuffix" |
|||
java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar bin/xxl-job-admin-mysql-2.3.0.jar --spring.config.location=conf/ --spring.profiles.active=global,$profiles --server.port=8001 >>/dev/null 2>&1 & |
|||
echo "$serverName 启动成功!" |
|||
else |
|||
echo "$serverName 正在运行..." |
|||
fi |
|||
echo "查看日志: tail -F $logPath -n 100" |
|||
} |
|||
|
|||
stopServer() { |
|||
pid=$1 |
|||
if [ -z $pid ];then |
|||
echo "$serverName 未运行" |
|||
else |
|||
echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" |
|||
ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill |
|||
echo "$serverName 已停止!" |
|||
fi |
|||
} |
|||
|
|||
restartServer() { |
|||
pid=$1 |
|||
if [ ! -z $pid ];then |
|||
stopServer $pid |
|||
sleep 3s |
|||
fi |
|||
startServer |
|||
} |
|||
|
|||
logs() { |
|||
tail -F $logPath -n 100 |
|||
} |
|||
|
|||
pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` |
|||
# 操作参数: deploy restart start stop kill log logs |
|||
if [ "$cmd" == "deploy" ];then |
|||
restartServer $pid |
|||
elif [ "$cmd" == "restart" ];then |
|||
restartServer $pid |
|||
elif [ "$cmd" == "start" ];then |
|||
startServer $pid |
|||
elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then |
|||
stopServer $pid |
|||
elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then |
|||
logs |
|||
else |
|||
if [ -z $pid ];then |
|||
echo "$serverName 未运行 | 输入操作参数: deploy restart start stop kill log logs" |
|||
else |
|||
echo "输入操作参数: deploy restart start stop kill log logs" |
|||
echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" |
|||
fi |
|||
fi |
|||
|
|||
# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/hua_wei_yun/01xxljob.sh) [cmd profiles] |
|||
Loading…
Reference in new issue