windows批处理实现自动更新部署Web项目
程序员文章站
2022-07-03 15:50:12
...
根据windows守护tomcat的bat批处理脚本增强功能
原理:发现webapps目录下有新的ROOT.war包进行解压替换,重启tomcat
@echo off
setlocal enabledelayedexpansion
set TOMCAT_HOME=C:\utils\apache-tomcat-7.0.65
set TOMCAT_PORT=8080
:RESTART
cd %TOMCAT_HOME%\webapps
if exist ROOT.war (
move /y ROOT.war ROOT
cd ROOT
start /wait "" "C:\Program Files\WinRAR\WinRAR.exe" x -y ROOT.war
for /f "delims= tokens=1" %%i in ('netstat -aon ^| findstr "%TOMCAT_PORT%"') do (
set a=%%i
taskkill /pid "!a:~71,5!"
)
)
cd /d %~dp0
netstat -an | find /C "0.0.0.0:%TOMCAT_PORT%" > temp.txt
set /p num=<temp.txt
del /F temp.txt
if %num%==0 (
start /D "%TOMCAT_HOME%\bin\" startup.bat
)
cd /d %~dp0
echo Wscript.Sleep WScript.Arguments(0) >sleep.vbs
cscript //b //nologo sleep.vbs 5000
goto RESTART
转载于:https://my.oschina.net/u/565871/blog/536041
上一篇: logback