Skip to content

Instantly share code, notes, and snippets.

@RobinUS2
Created January 9, 2013 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RobinUS2/4491765 to your computer and use it in GitHub Desktop.
Save RobinUS2/4491765 to your computer and use it in GitHub Desktop.
Hive server availability check
#!/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