start.sh 2.3 KB

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