sparkthor.sh.in 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.sh.debug
  21. #set -x
  22. export logfile="@LOG_PATH@/${_component}/sparkthor.log"
  23. source @INSTALL_DIR@/sbin/hpcc_setenv
  24. source @INSTALL_DIR@/etc/init.d/hpcc_common
  25. source ./spark-hpcc-env.sh
  26. # update slaves file in case state of environment has been altered since last run
  27. errorMessage=$( @EXEC_PATH@/daliadmin server=$DALISERVER clusternodes ${NODEGROUP} @RUNTIME_PATH@/${_component}/slaves 2>&1 )
  28. errcode=$?
  29. if [[ 0 != ${errcode} ]]; then
  30. log "failed to lookup dali group for ${component}"
  31. log "$errorMessage"
  32. exit 1
  33. fi
  34. log "${_command} master"
  35. @INSTALL_DIR@/externals/spark-hadoop/sbin/${_command}-master.sh
  36. if [[ -f "@RUNTIME_PATH@/${_component}/slaves" ]]; then
  37. log "Starting sparkthor-workers with ./frunssh @RUNTIME_PATH@/${_component}/slaves"
  38. clusternodes=$(cat @RUNTIME_PATH@/${_component}/slaves | wc -l)
  39. @EXEC_PATH@/frunssh @RUNTIME_PATH@/${_component}/slaves "/bin/sh -c '@ADMIN_PATH@/sparkthor-worker.sh ${_command} ${_component}'" -i:$SSHidentityfile -u:$SSHusername -pe:$SSHpassword -t:$SSHtimeout -a:$SSHretries -n:$clusternodes 2>&1
  40. FRUNSSH_RC=$?
  41. if [[ ${FRUNSSH_RC} -gt 0 ]]; then
  42. log "Error ${FRUNSSH_RC} in frunssh"
  43. log "Please check @LOG_PATH@/frunssh for more details"
  44. exit 255
  45. else
  46. log "Frunssh successful"
  47. fi
  48. else
  49. @ADMIN_PATH@/sparkthor-worker.sh ${_command} ${_component}
  50. fi
  51. exit 0