deploy-prod2.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bash/sh
  2. TARGET_MODULE=""
  3. if [ "$1" == "appservice" ]
  4. then
  5. TARGET_MODULE="xchat-web-api"
  6. elif [ "$1" == "record" ]
  7. then
  8. TARGET_MODULE="xchat-web-record"
  9. elif [ "$1" == "task" ]
  10. then
  11. TARGET_MODULE="xchat-web-task"
  12. fi
  13. TARGET_USER="root"
  14. TARGET_IP="120.78.13.246"
  15. TARGET_FROM_BASE="/home/chensenlai/shanp/project/chat-server/apiservice/"
  16. TARGET_FROM="${TARGET_MODULE}/target/$1.jar"
  17. TARGET_TO_BASE="/srv/server/chat-server/$1/"
  18. TARGET_TO="$1.jar"
  19. TARGET_TO_SWAP="${TARGET_TO}.swap"
  20. if [ -z TARGET_MODULE ]
  21. then
  22. echo -e "\033[35merror: unkonw target. [appservice|record|task]\033[0m"
  23. exit -1
  24. fi
  25. echo "cd into ${TARGET_FROM_BASE}${TARGET_FROM}"
  26. cd ${TARGET_FROM_BASE}
  27. #echo -e "\033[35m 0) switch branch ... \033[0m"
  28. #git checkout dev
  29. #echo -e "\033[35m 1) git pull ... \033[0m"
  30. #git pull
  31. echo " 2) build project $1..."
  32. mvn clean
  33. mvn install -Pprod -pl ${TARGET_MODULE} -am
  34. echo " 3) scp to ${TARGET_USER}@${TARGET_IP}:${TARGET_TO_BASE}${TARGET_TO_SWAP}"
  35. scp ${TARGET_FROM_BASE}${TARGET_FROM} ${TARGET_USER}@${TARGET_IP}:${TARGET_TO_BASE}${TARGET_TO_SWAP}
  36. echo " 4) ${TARGET_USER}@${TARGET_IP} ${TARGET_TO_BASE}run.sh restart..."
  37. ssh -l ${TARGET_USER} ${TARGET_IP} "cd ${TARGET_TO_BASE};
  38. mv ${TARGET_TO_SWAP} ${TARGET_TO};
  39. sh run.sh restart"
  40. echo done!
  41. exit 0