ry.bat 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. @echo off
  2. rem jar平级目录
  3. set AppName=ruoyi-admin.jar
  4. rem JVM参数
  5. set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
  6. ECHO.
  7. ECHO. [1] 启动%AppName%
  8. ECHO. [2] 关闭%AppName%
  9. ECHO. [3] 重启%AppName%
  10. ECHO. [4] 启动状态 %AppName%
  11. ECHO. [5] 退 出
  12. ECHO.
  13. ECHO.请输入选择项目的序号:
  14. set /p ID=
  15. IF "%id%"=="1" GOTO start
  16. IF "%id%"=="2" GOTO stop
  17. IF "%id%"=="3" GOTO restart
  18. IF "%id%"=="4" GOTO status
  19. IF "%id%"=="5" EXIT
  20. PAUSE
  21. :start
  22. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do (
  23. set pid=%%a
  24. set image_name=%%b
  25. )
  26. if defined pid (
  27. echo %%is running
  28. PAUSE
  29. )
  30. start javaw %JVM_OPTS% -jar %AppName%
  31. echo starting……
  32. echo Start %AppName% success...
  33. goto:eof
  34. rem 函数stop通过jps命令查找pid并结束进程
  35. :stop
  36. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do (
  37. set pid=%%a
  38. set image_name=%%b
  39. )
  40. if not defined pid (echo process %AppName% does not exists) else (
  41. echo prepare to kill %image_name%
  42. echo start kill %pid% ...
  43. rem 根据进程ID,kill进程
  44. taskkill /f /pid %pid%
  45. )
  46. goto:eof
  47. :restart
  48. call :stop
  49. call :start
  50. goto:eof
  51. :status
  52. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do (
  53. set pid=%%a
  54. set image_name=%%b
  55. )
  56. if not defined pid (echo process %AppName% is dead ) else (
  57. echo %image_name% is running
  58. )
  59. goto:eof