战争文件自动部署

huangapple go评论108阅读模式
英文:

War file automated deployment

问题

所以我会自动在 Linux 服务器上部署 WAR 文件,使用 Java 进行操作。

而且总是使用相同的命令:

ps -ef | grep java
kill -9 (Java 进程)
java -jar ROOT.war &>/dev/null &

然而,我会得到不同的版本,比如:

ROOT_1.0.2.war
ROOT_1.0.3.war
ROOT_1.0.4.war
ROOT_1.0.5.war

我想要脚本能够检测到新的 .war 文件,并自动部署它,并且保持部署状态,这就是我使用 &>/dev/null & 的原因,这样它会一直运行,直到再次被终止,直到新版本被放入该目录中。

英文:

So I deploy war files on a Linux box using java automatically

and the same commands are always used

ps -ef | grep java
kill - 9 (java process)
java -jar ROOT.war &>/dev/null &

However, I get different versions for it so like

ROOT_1.0.2.war
ROOT_1.0.3.war
ROOT_1.0.4.war
ROOT_1.0.5.war

I want the script to see the new .war and deploy it automatically
and keep it deployed which is why I use &>/dev/null & so it runs in the till it is killed again till the new version is put in that directory

答案1

得分: 0

echo 输入您想要终止的进程名称,例如ROOT.war?
输入代码如下:
read process

终止选定的进程

file="$process"
if [ -f "$file" ];
then
pkill -9 -f $process
echo 进程已停止 >> satrixWar.txt
sleep 3s

启动选定的进程

echo 输入您想要启动的进程名称
read process2
java -jar $process2 &>/dev/null &
echo 进程正在启动 >> satrixWar.txt

else
echo "进程 $process 不存在" >&2
fi

确认新进程是否已启动

echo 当前安装内容 >> satrixWar.txt
ps -ef | grep $process2 >> satrixWar.txt

mail -a 文本文件路径 -s "名称"
"email.com" < /dev/null

rm -rf War.txt

英文:
echo Enter the name of the process you want to kill eg ROOT.war?
enter code here
read process

##Kill selected process 
file=&quot;$process&quot;
 if [ -f &quot;$file&quot; ];
then
   pkill -9 -f $process
   echo process stopped &gt;&gt; satrixWar.txt
 sleep 3s

## Start Up selected process 
echo Enter the name of the process you want to start
read process2
java -jar $process2 &amp;&gt;/dev/null &amp;
echo process starting up&gt;&gt; satrixWar.txt

else
   echo &quot;Process $process does not exist&quot; &gt;&amp;2
fi

##Confirm new proess is up
echo What is currently installed &gt;&gt; satrixWar.txt 
ps -ef | grep $process2 &gt;&gt; satrixWar.txt

mail -a text file path -s &quot;name&quot; 
&quot;email.com&quot; &lt; /dev/null

rm -rf War.txt

huangapple
  • 本文由 发表于 2020年4月3日 21:22:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/61012900.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定