sparkthor-worker.sh.in 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. ################################################################################
  3. # HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. ################################################################################
  17. _command=${1:-start}
  18. _component=${2:-mysparkthor}
  19. #### Uncomment following lines for verbose debugging
  20. #exec 3>&2 2>@LOG_PATH@/${_component}/sparkthor-worker.${_command}.debug
  21. #set -x
  22. export logfile="@LOG_PATH@/${_component}/sparkthor-worker.log"
  23. source @INSTALL_DIR@/etc/init.d/hpcc_common
  24. if [[ "${_command}" == "start" ]]; then
  25. mkdir -p @RUNTIME_PATH@/${_component} @LOCK_PATH@ @PID_PATH@ @LOG_PATH@/${_component}
  26. fi
  27. cd @RUNTIME_PATH@/${_component}
  28. MASTER_IP="$(@ADMIN_PATH@/configgen -env @CONFIG_DIR@/@ENV_XML_FILE@ -listall -c ${_component} | awk -F "," '{print $3;}')"
  29. log "rsync -e \"ssh -o LogLevel=QUIET -o StrictHostKeyChecking=no\" --timeout=60 ${MASTER_IP}:@RUNTIME_PATH@/${_component}/spark-hpcc-env.sh @RUNTIME_PATH@/${_component}/spark-hpcc-env.sh"
  30. rsync_att=3
  31. rsync_stat=1
  32. while [[ $rsync_stat -ne 0 && $rsync_att -gt 0 ]] ; do
  33. rsync -e "ssh -o LogLevel=QUIET -o StrictHostKeyChecking=no" --timeout=60 ${MASTER_IP}:@RUNTIME_PATH@/${_component}/spark-hpcc-env.sh spark-hpcc-env.sh
  34. rsync_stat=$?
  35. ((rsync_att--))
  36. log "rsync returns ${rsync_stat}"
  37. done
  38. if [ ! -f @RUNTIME_PATH@/${_component}/spark-hpcc-env.sh ] ; then
  39. log "Error, $workersfname file missing"
  40. exit 1
  41. fi
  42. source @RUNTIME_PATH@/${_component}/spark-hpcc-env.sh
  43. MASTER_URL="spark://${MASTER_IP}:${SPARK_MASTER_PORT}"
  44. #external provided spark-hadoop file
  45. @INSTALL_DIR@/externals/spark-hadoop/sbin/${_command}-slave.sh ${MASTER_URL}