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