mooctestOrgBackend 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. version="1.0.1";
  3. BASE_DIR=/tmp
  4. appName=mooctest-report-service-1.0-SNAPSHOT.jar
  5. if [ -z $appName ];then
  6. appName=`ls -t |grep .jar$ |head -n1`
  7. fi
  8. function start()
  9. {
  10. count=`ps -ef |grep java|grep $appName|wc -l`
  11. if [ $count != 0 ];then
  12. echo "Maybe $appName is running, please check it..."
  13. else
  14. echo "The $appName is starting..."
  15. nohup java -jar ./$appName -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -Xms512M -Xmx4G > /dev/null 2>&1 &
  16. fi
  17. }
  18. function stop()
  19. {
  20. appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
  21. if [ -z $appId ];then
  22. echo "Maybe $appName not running, please check it..."
  23. else
  24. echo "The $appName is stopping..."
  25. kill $appId
  26. fi
  27. }
  28. function restart()
  29. {
  30. # get release version
  31. releaseApp=`ls -t |grep .jar$ |head -n1`
  32. # get last version
  33. lastVersionApp=`ls -t |grep .jar$ |head -n2 |tail -n1`
  34. appName=$lastVersionApp
  35. stop
  36. for i in {5..1}
  37. do
  38. echo -n "$i "
  39. sleep 1
  40. done
  41. echo 0
  42. appName=$releaseApp
  43. start
  44. }
  45. function status()
  46. {
  47. appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
  48. if [ -z $appId ]
  49. then
  50. echo -e "\033[31m Not running \033[0m"
  51. else
  52. echo -e "\033[32m Running [$appId] \033[0m"
  53. fi
  54. }
  55. function usage()
  56. {
  57. echo "Usage: $0 {start|stop|restart|status|stop -f}"
  58. echo "Example: $0 start"
  59. exit 1
  60. }
  61. case $1 in
  62. start)
  63. start;;
  64. stop)
  65. stop;;
  66. restart)
  67. restart;;
  68. status)
  69. status;;
  70. *)
  71. usage;;
  72. esac