shutdown.sh 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. JAVA_HOME=$JAVA_HOME
  3. JAVA_OPTS=$JAVA_OPTS
  4. ECHO_PREFIX="[DataGear] :"
  5. APP_MAIN="${productNameJar}"
  6. APP_PID=0
  7. if [ -n "$JAVA_HOME" ]; then
  8. echo "$ECHO_PREFIX using JAVA_HOME '$JAVA_HOME'"
  9. else
  10. java -version
  11. echo ""
  12. echo "$ECHO_PREFIX using previous java runtime"
  13. fi
  14. readAppPID()
  15. {
  16. if [ -n "$JAVA_HOME" ]; then
  17. JAVAPS=`$JAVA_HOME/bin/jps -l | grep "$APP_MAIN"`
  18. if [ -n "$JAVAPS" ]; then
  19. APP_PID=`echo $JAVAPS | awk '{print $1}'`
  20. else
  21. APP_PID=0
  22. fi
  23. else
  24. JAVAPS=`ps -ef | grep "$APP_MAIN" | grep -v grep`
  25. if [ -n "$JAVAPS" ]; then
  26. APP_PID=`echo $JAVAPS | awk '{print $2}'`
  27. else
  28. APP_PID=0
  29. fi
  30. fi
  31. }
  32. readAppPID
  33. if [ $APP_PID -ne 0 ]; then
  34. echo "$ECHO_PREFIX stopping... (PID=$APP_PID)"
  35. kill -9 $APP_PID
  36. if [ $? -eq 0 ]; then
  37. echo "$ECHO_PREFIX stopping [OK]"
  38. else
  39. echo "$ECHO_PREFIX stopping [Failed]"
  40. fi
  41. else
  42. echo "$ECHO_PREFIX application is not running"
  43. echo "$ECHO_PREFIX stopping [Failed]"
  44. fi