build.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. #
  3. #
  4. ### springboot的服务路径
  5. APP_DIR=/opt/zjy/smartid/smartid-server
  6. #//springboot的服务名称
  7. APP_NAME=smartid-server
  8. APP_CONF=$APP_DIR/online/application.properties
  9. #set java home
  10. export JAVA_HOME=/usr/local/java/jdk1.8.0_161
  11. usage() {
  12. echo "Usage: sh eju-micro-app.sh [start|stop|deploy]"
  13. exit 1
  14. }
  15. kills(){
  16. tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
  17. if [[ $tpid ]]; then
  18. echo 'Kill Process!'
  19. kill -9 $tpid
  20. fi
  21. }
  22. start(){
  23. rm -f $APP_DIR/tpid
  24. #nohup java -jar myapp.jar --spring.config.location=application.yml > /dev/null 2>&1 &
  25. nohup java -jar $APP_DIR/target/smartid-server-0.1.0-SNAPSHOT.jar > /dev/null 2>&1 &
  26. echo $! > $APP_DIR/tpid
  27. echo Start Success!
  28. }
  29. stop(){
  30. tpid1=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
  31. echo tpid1-$tpid1
  32. if [[ $tpid1 ]]; then
  33. echo 'Stop Process...'
  34. kill -15 $tpid1
  35. fi
  36. sleep 5
  37. tpid2=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
  38. echo tpid2-$tpid2
  39. if [[ $tpid2 ]]; then
  40. echo 'Kill Process!'
  41. kill -9 $tpid2
  42. else
  43. echo 'Stop Success!'
  44. fi
  45. }
  46. check(){
  47. tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
  48. if [[ tpid ]]; then
  49. echo 'App is running.'
  50. else
  51. echo 'App is NOT running.'
  52. fi
  53. }
  54. deploy() {
  55. kills
  56. rm -rf $APP_DIR/"$APPNAME".jar
  57. cp "$APP_NAME".jar $APP_DIR
  58. }
  59. case "$1" in
  60. "start")
  61. start
  62. ;;
  63. "stop")
  64. stop
  65. ;;
  66. "kill")
  67. kills
  68. ;;
  69. "deploy")
  70. deploy
  71. ;;
  72. *)
  73. usage
  74. ;;
  75. esac