shell

#!/bin/bash

PID=$(ps-ef|grepyourappp.jar|grep-vgrep|awk'{print$2}')

if[-z"$PID"]

then

echoAssetisalreadystopped!

else

echokill$PID

kill$PID

echoAssetstopped!

fi

#!/usr/bin/envbash

#Author:Linqinghong

#CreateTime:2018/05/12/10:07

#Description:

source/etc/profile

#================VarBegin====================

serviceName=$2

serviceDir="/ddhome/local/service"

jarname="$serviceName.jar"

mainclass="com.hw.Application"

tag="$serviceName"

libDir="$serviceDir/lib"

logOutputFormat=$(date+%b""%d""%H:%M:%S""`hostname`)

jvmParam="-Xmx2048M-Xms2048M-XX:PermSize=512M-XX:MaxPermSize=512M"

#================VarEnd====================

#================FunctionBegin====================

start(){

cd$serviceDir

runningJarCount=$(ps-ef|grepjava|grep-w$tag|wc-l)

if[$runningJarCount-gt0];then

echo"$logOutputFormat$tagisrunning."

else

$JAVA_HOME/bin/java$jvmParam-Dir=$tag$mainClass

echo"$logOutputFormatReadytostart$tag,ifuwannaseethebootstrapprocessof$tag,pleasetailtheconsole.out."

fi

}

stop(){

echo"$logOutputFormatReadytostop$tag."

runningJarCount=$(ps-ef|grepjava|grep-w$tag|wc-l)

if[$runningJarCount-gt0];then

ps-ef|grepjava|grep-w$tag|grep-vgrep|awk'{print$2}'|xargs-n1kill-9

fi

echo"$logOutputFormat$tagwasstopped."

}

#================FunctionEnd====================

if[!-f$serviceDir/$serviceName/$jarName];then

echo"Cannotfind$serviceDir/$serviceName/$jarName."

exit

fi

forlibin$libDir/*.jar

do

libs=$lib:$libs

done

CLASSPATH=$libs$serviceDir/$serviceName/$jarName

exportCLASSPATH

#==================EntranceBegin===============

case"$1"in

start)

start

;;

stop)

stop

;;

restart)

stop

sleep5

start

;;

*)

echo"Usage:$0{start|stop|restart}+serviceName"

exit2

esac

#==================EntranceEnd===============

#!/bin/sh

#Tomcat的webapps地址

tomcat_webapps_path=/ddhome/bin/tomcat/webapps/

#github项目地址

github_url=http://[email protected]/dev/huayun.git

#截取"/"右边的

tmp=${github_url##*/}

#截取"."左边的

project_name=${tmp%%.*}

echo"========="$project_name===============

#没有更新标志

b="Already"

c="up-to-date"

#判断是否已经clone过了

if[!-d"$project_name"]

then

rm-rf$project_name

#获取命令执行的结果

a=$(gitclone$github_url2>&1)

cd$project_name

echo$a

else

cd$project_name

echo"=========begingitpull============"

#获取pull的结果

a=$(gitpulloriginmaster2>&1)

echo$a

fi

#如果结果中包含相关的字段,则认为没有更新,退出不进行打包部署

echo$a

echo$b

echo$c

#输出字符串是否包含关键字更新

if[[$a=~$b]]

then

echo------------noupdate-------------

exit0

elif[[$a=~$c]]

then

echo------------noupdate-------------

exit0

fi

echo"============beginpackage=========="

rm-rftarget

#开始打包

mvnpackage

cdtarget/

#开始部署,此方式不妥当,应该通过gui进行部署,有兴趣的自己实现

#停止Tomcat服务

systemctlstoptomcat

rm-rf${tomcat_webapps_path}"ROOT"

#移动到Tomcat目录下并自动命名

mv-u*.war${tomcat_webapps_path}"ROOT.war"

#重启Tomcat服务

systemctlstarttomcat

echo"=============deployend============="

https://blog.csdn.net/dream_catcher_10/article/details/48174541

相关推荐