stop-data-processors.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. 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. bin=`dirname "$0"`
  17. bin=`cd "$bin"; pwd`
  18. java=$JAVA_HOME/bin/java
  19. . "$bin"/chukwa-config.sh
  20. # stop processSinkFiles.sh
  21. pidFile=$CHUKWA_PID_DIR/ProcessSinkFiles.pid
  22. if [ -f $pidFile ]; then
  23. echo -n "Shutting down Data Processors.."
  24. DP_PID=`head ${pidFile}`
  25. kill -TERM ${DP_PID}
  26. for i in 1 2 5; do
  27. test_pid=`ps ax | grep ${DP_PID} | grep -v grep | grep processSinkFiles.sh | wc -l`
  28. if [ $test_pid -ge 1 ]; then
  29. sleep $i
  30. kill -TERM ${DP_PID}
  31. else
  32. break
  33. fi
  34. done
  35. test_pid=`ps ax | grep ${DP_PID} | grep -v grep | grep processSinkFiles.sh | wc -l`
  36. if [ $test_pid -ge 1 ]; then
  37. kill -9 ${DBADMIN_PID} &>/dev/null
  38. fi
  39. rm -f ${pidFile}
  40. rm -f $CHUKWA_PID_DIR/chukwa-$CHUKWA_IDENT_STRING-processSinkFiles.sh.pid
  41. echo "done"
  42. else
  43. echo " no $pidFile"
  44. fi
  45. # stop dbAdmin.sh
  46. pidFile=$CHUKWA_PID_DIR/dbAdmin.pid
  47. if [ -f $pidFile ]; then
  48. echo -n "Shutting down Database Admin.."
  49. DBADMIN_PID=`head ${pidFile}`
  50. kill -TERM ${DBADMIN_PID}
  51. for i in 1 2 5; do
  52. test_pid=`ps ax | grep ${DBADMIN_PID} | grep -v grep | grep dbAdmin.sh | wc -l`
  53. if [ $test_pid -ge 1 ]; then
  54. sleep $i
  55. kill -TERM ${DBADMIN_PID}
  56. else
  57. break
  58. fi
  59. done
  60. test_pid=`ps ax | grep ${DBADMIN_PID} | grep -v grep | grep dbAdmin.sh | wc -l`
  61. if [ $test_pid -ge 1 ]; then
  62. kill -9 ${DBADMIN_PID} &>/dev/null
  63. fi
  64. rm -f ${pidFile}
  65. rm -f $CHUKWA_PID_DIR/chukwa-$CHUKWA_IDENT_STRING-dbAdmin.sh.pid
  66. echo "done"
  67. else
  68. echo " no $pidFile"
  69. fi