bash.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. APP_NAME=/usr/local/service/$2/$2.jar
  2. TARGET_PATH=/apps/intelligent-family
  3. source /etc/profile
  4. BUILD_ID=dontKillMe
  5. #启动方法
  6. start(){
  7. pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
  8. if [ "$pid" ]; then
  9. echo "$APP_NAME is already running. pid=$pid ."
  10. else
  11. setsid java -jar $APP_NAME --spring.profiles.active=dev >> out.log 2>&1 &
  12. sleep 10
  13. echo "$APP_NAME now is running"
  14. fi
  15. }
  16. #停止方法
  17. stop(){
  18. pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
  19. if [ "$pid" ]; then
  20. kill -9 $pid
  21. echo "Pid:$pid stopped"
  22. else
  23. echo "$APP_NAME is not running"
  24. fi
  25. }
  26. #输出运行状态
  27. status(){
  28. pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
  29. if [ "$pid" ]; then
  30. echo "$APP_NAME is running. Pid is ${pid}"
  31. else
  32. echo "$APP_NAME is NOT running."
  33. fi
  34. }
  35. #根据输入参数,选择执行对应方法,不输入则执行使用说明
  36. case "$1" in
  37. start)
  38. start
  39. ;;
  40. stop)
  41. stop
  42. ;;
  43. status)
  44. status
  45. ;;
  46. restart)
  47. stop
  48. sleep 5
  49. start
  50. ;;
  51. *)
  52. echo "Usage:{start|stop|status|restart}"
  53. ;;
  54. esac
  55. exit 0