Created
January 9, 2013 09:11
-
-
Save RobinUS2/4491765 to your computer and use it in GitHub Desktop.
Hive server availability check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
STATE=`ps aux | grep "HiveServer" | wc -l` | |
IP="127.0.0.1" | |
PORT=10000 | |
function do_restart() | |
{ | |
echo Restarting | |
cd / | |
nohup hive --service hiveserver & | |
echo $! > /var/run/hiveserver.pid | |
} | |
# Check for TCP socket + state in ps aux | |
exec 6<>/dev/tcp/$IP/$PORT || do_restart | |
if [ $STATE != "2" ] | |
then | |
do_restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment