bat 启动多个jar(window)

系统环境:

    window

1.场景

       随着微服务的广泛被应用,有时候,一个项目,可能会被拆分成多个服务,假设有50个服务,如果,我们还是通过一个个启动的方式,这样效率低不说,可能还会存在遗漏等问题,所以常见的方式,是采用脚本的方式,例如自动化持续构建工具jenkins,也是通过脚本的方式,进行自动化持续构建,这里,我们来论道论道window启动多个jar

2.脚本

新建一个文件,后缀为bat

@echo off

start taskkill /f /im javaw.exe
echo 'close all javaw project'
##为了保险起见等待进程3s关闭结束
ping 127.0.0.1 -n 10

##启动zk
start /d  "D:\zookeeper-3.4.12\bin\" zkServer.cmd
ping 127.0.0.1 -n 15

###启动采集后台
start /d  "D:\apache-tomcat-7.0.55\climate\bin\" startup.bat
ping 127.0.0.1 -n 15
###启动质控
start /d  "D:\apache-tomcat-7.0.55\qa\bin\" startup.bat
ping 127.0.0.1 -n 5
###启动秒级入库
start /d  "D:\apache-tomcat-7.0.55\savelog\bin\" startup.bat
ping 127.0.0.1 -n 5
###启动秒级解析
start /d  "D:\apache-tomcat-7.0.55\secondstation\bin\" startup.bat
ping 127.0.0.1 -n 5

###启动tide
start cmd /c "title tide && java -jar D:\apache-tomcat-7.0.55\tide.jar &"
ping 127.0.0.1 -n 5
##启动北斗
start cmd /c "title dipper && java -jar D:\apache-tomcat-7.0.55\dipper.jar &"
ping 127.0.0.1 -n 5
##启动梯度塔干湿球
start cmd /c "title wetdrybulb && java -jar D:\apache-tomcat-7.0.55\wetdrybulb.jar &"
ping 127.0.0.1 -n 5
##启动城市气候站
start cmd /c "title weatherstations && java -jar D:\apache-tomcat-7.0.55\weatherstations.jar &"
ping 127.0.0.1 -n 5
##启动530模块
start cmd /c "title WTX530 && java -jar D:\apache-tomcat-7.0.55\WTX530.jar &"
ping 127.0.0.1 -n 5
##启动AWS420梯度塔
start cmd /c "title AWS420 && java -jar D:\apache-tomcat-7.0.55\AWS420.jar &"
ping 127.0.0.1 -n 5
##启动船载站shipborne
start cmd /c "title shipborne && java -jar D:\apache-tomcat-7.0.55\shipborne.jar &"
ping 127.0.0.1 -n 5
###启动AWS310
start cmd /c "title AWS310 && java -jar D:\apache-tomcat-7.0.55\AWS310.jar &"
ping 127.0.0.1 -n 5
###启动WP3103
start cmd /c "title WP3103 && java -jar D:\apache-tomcat-7.0.55\WP3103.jar &"
ping 127.0.0.1 -n 5
###启动舒适度ComfortLevel
start cmd /c "title ComfortLevel && java -jar D:\apache-tomcat-7.0.55\ComfortLevel.jar &"
ping 127.0.0.1 -n 5
###启动回南天southday
start cmd /c "title southday && java -jar D:\apache-tomcat-7.0.55\southday.jar &"
ping 127.0.0.1 -n 5
pause 

 由于项目过多,这里我就不过多的列出来。

(1)taskkill /f /im javaw.exe -----删除java的进程,防止项目已经在运行,再启动包地址已绑定的错误。

(2)  taskkill下一句代码,为什么要ping ip一段时间,也是防止

(3) 每个服务后,建议延迟5s左右,经过测试,发现时间过短, 有级别服务,没有启动成功

发布了261 篇原创文章 · 获赞 344 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/qq_16855077/article/details/103426709