start.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. export JAVA_HOME=/root/jdk1.8.0_181
  3. export PATH=$JAVA_HOME/bin:$PATH
  4. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  5. bashPath=/root/maxcompute_job/flow
  6. odps_cmd=/root/maxcompute_job/flow/odpscmd
  7. debug=0
  8. if [ $# -eq 0 ]; then
  9. echo "---------------------------------------------------------------------------"
  10. # OS Type
  11. echo " OS Type: $(uname -o)"
  12. # OS Release Version and Name
  13. echo "OS Release Version and Name: $(cat /etc/issue | head -n 1)"
  14. #Architecture
  15. echo " Architecture: $(uname -m)"
  16. #Kernel Release
  17. echo " Kernel Release: $(uname -r)"
  18. #hostname
  19. echo " hostname: $HOSTNAME"
  20. #Internal IP
  21. echo " Internal IP: $(hostname -I)"
  22. #External IP
  23. echo " External IP: $(curl --connect-timeout 10 -m 20 -s ipecho.net/plain)"
  24. #DNS
  25. dnsservers=""
  26. for i in $(cat /etc/resolv.conf | grep '^nameserver' | awk '{print $NF}'); do
  27. dnsservers="$dnsservers$i "
  28. done
  29. echo " DNS: $dnsservers"
  30. #if connected to Internet or not
  31. echo " internet status: $(ping -c 2 www.baidu.com &>/dev/null && echo 'connected' || echo 'disconnected')"
  32. echo "---------------------------------------------------------------------------"
  33. fi
  34. if [ $# -eq 1 ]; then
  35. echo "启动debug模式"
  36. debug=1
  37. fi
  38. start_job() {
  39. echo "start job:$1"
  40. if [ $# -lt 1 ]; then
  41. echo ""
  42. # shellcheck disable=SC2242
  43. exit -1
  44. fi
  45. if [ $debug -eq 1 ]; then
  46. echo "debug model。。。"
  47. java -jar $bashPath/DataWorks-flow-touch.jar -f $bashPath/jobs/$1 -d
  48. return
  49. else
  50. echo ""
  51. java -jar $bashPath/DataWorks-flow-touch.jar -f $bashPath/jobs/$1 -odps $odps_cmd
  52. fi
  53. if [ $? -eq 0 ]; then
  54. echo "$1 succeed"
  55. else
  56. echo "$1 failed"
  57. exit $?
  58. fi
  59. }
  60. # shellcheck disable=SC2164
  61. cd $bashPath/repo
  62. git pull origin master # 拉取仓库
  63. cd ..
  64. java -jar $bashPath/DataWorks-flow-touch.jar -w
  65. if [ $? -eq 0 ]; then
  66. echo "上游数据已同步完成!"
  67. else
  68. echo "上游数据长时间未同步完成,程序中止!"
  69. exit $?
  70. fi
  71. java -jar $bashPath/DataWorks-flow-touch.jar -q
  72. if [ $? -eq 0 ]; then
  73. echo "company is not empty!"
  74. else
  75. echo "company is empty!"
  76. exit $?
  77. fi
  78. job_files=(task-step01.yaml task-step02.yaml task-step03.yaml task-step04.yaml)
  79. for e in ${job_files[@]}; do
  80. start_job $e
  81. done
  82. echo "end"