ry.bat 1.6 KB

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