ry.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. # author ruoyi
  3. # ./ry.sh start 启动
  4. # ./ry.sh stop 停止
  5. # ./ry.sh restart 重启
  6. # ./ry.sh status 状态
  7. AppName=ruoyi-admin.jar
  8. # JVM参数
  9. JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
  10. APP_HOME=`pwd`
  11. LOG_PATH=$APP_HOME/logs/$AppName.log
  12. if [ "$1" = "" ];
  13. then
  14. echo -e "\033[0;31m 未输入操作名 \033[0m \033[0;34m {start|stop|restart|status} \033[0m"
  15. exit 1
  16. fi
  17. if [ "$AppName" = "" ];
  18. then
  19. echo -e "\033[0;31m 未输入应用名 \033[0m"
  20. exit 1
  21. fi
  22. function start()
  23. {
  24. PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`
  25. if [ x"$PID" != x"" ]; then
  26. echo "$AppName is running..."
  27. else
  28. nohup java -jar $JVM_OPTS target/$AppName > /dev/null 2>&1 &
  29. echo "Start $AppName success..."
  30. fi
  31. }
  32. function stop()
  33. {
  34. echo "Stop $AppName"
  35. PID=""
  36. query(){
  37. PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`
  38. }
  39. query
  40. if [ x"$PID" != x"" ]; then
  41. kill -TERM $PID
  42. echo "$AppName (pid:$PID) exiting..."
  43. while [ x"$PID" != x"" ]
  44. do
  45. sleep 1
  46. query
  47. done
  48. echo "$AppName exited."
  49. else
  50. echo "$AppName already stopped."
  51. fi
  52. }
  53. function restart()
  54. {
  55. stop
  56. sleep 2
  57. start
  58. }
  59. function status()
  60. {
  61. PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l`
  62. if [ $PID != 0 ];then
  63. echo "$AppName is running..."
  64. else
  65. echo "$AppName is not running..."
  66. fi
  67. }
  68. case $1 in
  69. start)
  70. start;;
  71. stop)
  72. stop;;
  73. restart)
  74. restart;;
  75. status)
  76. status;;
  77. *)
  78. esac