PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.2.0-rc0/scripts/hcat_server_stop.sh

#
Shell | 67 lines | 35 code | 9 blank | 23 comment | 6 complexity | d497a7e3e30420e5210ebf3150143ea9 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. #!/bin/sh
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Resolve our absolute path
  18. # resolve links - $0 may be a softlink
  19. this="${BASH_SOURCE-$0}"
  20. while [ -h "$this" ]; do
  21. ls=`ls -ld "$this"`
  22. link=`expr "$ls" : '.*-> \(.*\)$'`
  23. if expr "$link" : '.*/.*' > /dev/null; then
  24. this="$link"
  25. else
  26. this=`dirname "$this"`/"$link"
  27. fi
  28. done
  29. # convert relative path to absolute path
  30. bin=`dirname "$this"`
  31. script=`basename "$this"`
  32. bin=`unset CDPATH; cd "$bin"; pwd`
  33. this="$bin/$script"
  34. # the root of the HCatalog installation
  35. export HCAT_HOME=`dirname "$this"`/..
  36. # Read the env file created by the install script
  37. . $HCAT_HOME/conf/hcat-env.sh
  38. PID_FILE=${ROOT}/var/log/hcat.pid
  39. SLEEP_TIME_AFTER_KILL=30
  40. echo looking for $PID_FILE
  41. # check if service is already running, if so exit
  42. if [ -s "$PID_FILE" ] ; then
  43. PID=`cat $PID_FILE`
  44. echo "Found metastore server process $PID, killing..."
  45. kill $PID
  46. sleep $SLEEP_TIME_AFTER_KILL
  47. # if process is still around, use kill -9
  48. if ps -p $PID > /dev/null ; then
  49. echo "Initial kill failed, getting serious now..."
  50. kill -9 $PID
  51. fi
  52. if ps -p $PID > /dev/null ; then
  53. echo "Wow, even kill -9 failed, giving up; sorry"
  54. else
  55. rm -rf $PID_FILE
  56. echo "Successfully shutdown metastore"
  57. fi
  58. fi