Windows系统部署脚本
脚本需要使用jps命令 需要JDK1.8以上环境使用多服务脚本 一个脚本搞定所有
脚本使用解析:
//开启所有服务(脚本名为Admp.bat)Admp.bat startAll//关闭所有服务Admp.bat stopAll//查看多个服务状态Admp.bat statusAll//开启单个服务(结合脚本中版本号进行编辑)Admp.bat start 服务名//关闭单个服务(结合脚本中版本号进行编辑)Admp.bat stop 服务名//重启单个服务(结合脚本中版本号进行编辑)Admp.bat restart 服务名//查看单个服务状态(结合脚本中版本号进行编辑)Admp.bat status 服务名
脚本内容:
@echo off set operation=%1set jarName=%2set jarHead=xxx-xxx-xxx-set jarTail=-1.0.0_xxxxxx_beta.jarsetlocal enabledelayedexpansion set apps[0]= %jarHead%eureka%jarTail% set apps[1]= %jarHead%auth%jarTail% set apps[2]= %jarHead%xxx-xxx%jarTail% set apps[3]= %jarHead%xxx-xxx%jarTail% set apps[4]= %jarHead%xxx-xxx%jarTail%set apps[5]= %jarHead%xxx-xxx%jarTail% set apps[6]= %jarHead%xxxxxx%jarTail% set apps[7]= %jarHead%xxxxx%jarTail% set apps[8]= %jarHead%xxxx%jarTail% set apps[9]= %jarHead%xxxx%jarTail% set apps[10]= %jarHead%xxxx%jarTail%set apps[11]= %jarHead%xxxx%jarTail% set apps[12]= %jarHead%xxx%jarTail% set apps[13]= %jarHead%xxx%jarTail%if "%operation%"=="start" (echo "Start %jarName% ..."start javaw -jar -Xms1024m -Xmx1024m -Dspring.profiles.active=prod %jarName%echo "Start %jarName% Success..."jps -l|findStr "%jarName%") else if "%operation%"=="stop" (echo "Stop %jarName%"for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %jarName%`) do (taskkill /f /pid %%a)echo "Stop %jarName% Success...") else if "%operation%"=="restart" (echo "ReStart %jarName% ..."for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %jarName%`) do (taskkill /f /pid %%aecho "Restart %jarName% ..."start javaw -jar %jarName%jps -l|findStr "%jarName%")echo "Restart %jarName% Success...") else if "%operation%"=="status" (jps -l|findStr "%jarName%") else if "%operation%"=="startAll" ( for /l %%b in (0,1,13) do (echo "Start !apps[%%b]!"start javaw -jar -Xms1024m -Xmx1024m -Dspring.profiles.active=prod !apps[%%b]!echo "Start !apps[%%b]! Success..."jps -l|findStr !apps[%%b]!)) else if "%operation%"=="stopAll" (for /l %%b in (0,1,13) do (echo "Stop !apps[%%b]!"for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr !apps[%%b]!`) do (taskkill /f /pid %%a)echo "Stop !apps[%%b]! Success...")) else if "%operation%"=="statusAll" ( for /l %%b in (0,1,13) do (echo "!apps[%%b]! status--------"jps -l|findStr !apps[%%b]!)) else (echo "Usage: execJar.bat [startAll|stopAll|statusAll|start|stop|restart|status]")
希望能够对你有所帮助!
如果觉得《Window jar包启动脚本》对你有帮助,请点赞、收藏,并留下你的观点哦!