英文:
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="$process"
if [ -f "$file" ];
then
pkill -9 -f $process
echo process stopped >> satrixWar.txt
sleep 3s
## Start Up selected process
echo Enter the name of the process you want to start
read process2
java -jar $process2 &>/dev/null &
echo process starting up>> satrixWar.txt
else
echo "Process $process does not exist" >&2
fi
##Confirm new proess is up
echo What is currently installed >> satrixWar.txt
ps -ef | grep $process2 >> satrixWar.txt
mail -a text file path -s "name"
"email.com" < /dev/null
rm -rf War.txt
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论