stop.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. APP_HOME=$(dirname $0)
  3. usage() {
  4. echo "Usage:" $0 "[api/app/sig/web]"
  5. echo "STOP tsi-api-server:" $0 "api"
  6. echo "STOP tsi-app-server:" $0 "app"
  7. echo "STOP tsi-sig-server:" $0 "sig"
  8. echo "STOP tsi-web-server:" $0 "web"
  9. exit
  10. }
  11. case $1 in
  12. api)
  13. APP_NAME=tsi-api-server
  14. APP_VERSION=0.0.1
  15. ;;
  16. app)
  17. APP_NAME=tsi-app-server
  18. APP_VERSION=0.0.1
  19. ;;
  20. sig)
  21. APP_NAME=tsi-sig-server
  22. APP_VERSION=0.0.1
  23. ;;
  24. web)
  25. APP_NAME=tsi-web-server
  26. APP_VERSION=0.0.1
  27. ;;
  28. *)
  29. usage
  30. ;;
  31. esac
  32. EXE_NAME=$APP_NAME-$APP_VERSION.jar
  33. PID_NAME=$APP_NAME.pid
  34. APP_PID=$APP_HOME/conf/$PID_NAME
  35. if [ ! -z "$APP_PID" ]; then
  36. if [ -f "$APP_PID" ]; then
  37. kill -15 `cat "$APP_PID"` >/dev/null 2>&1
  38. echo "$APP_NAME stopping.........."
  39. else
  40. echo "$APP_NAME is not running...."
  41. exit
  42. fi
  43. fi
  44. LOOP=$(seq 0 9)
  45. for i in $LOOP
  46. do
  47. sleep 1
  48. if [ -f "$APP_PID" ]; then
  49. echo "$APP_NAME stopping.........."
  50. else
  51. echo "$APP_NAME stopped.........."
  52. exit
  53. fi
  54. done
  55. echo "$APP_NAME cannot be terminated......."
  56. ps -eaf | grep $APP_NAME | grep -v grep