Skip to content

Instantly share code, notes, and snippets.

@shantanugadgil
Created January 2, 2020 07:12
Show Gist options
  • Save shantanugadgil/f1d6e091627a6a4200eea933c0b5c19e to your computer and use it in GitHub Desktop.
Save shantanugadgil/f1d6e091627a6a4200eea933c0b5c19e to your computer and use it in GitHub Desktop.
Zookeeper started script with some boilerplate stuff
#!/bin/bash
set -u
set -e
trap _error_exit ERR
_error_exit()
{
echo "ERROR EXIT"
exit 1
}
# redirect STDERR to STDOUT
exec 2>&1
declare -r _hname=$(hostname)
_log ()
{
local msg="$@"
local dd=$(date +"%Y-%m-%d %H:%M:%S")
echo "[$dd] [${_hname}] $msg"
return 0
}
_startup_debug ()
{
_log "########## DEBUG: BEGIN"
env | sort
_log "hostname [$(hostname)]"
_log "uname [$(uname -a)]"
_log "id [$(id -a)]"
_log "########## DEBUG: END"
return 0
}
### script starts here ###
zk_dir="$1"
conf_dir="$2"
/usr/bin/env | sort
_startup_debug
_log "zookeeperid [$ZOOKEEPER_ID]"
mkdir -p /var/lib/zookeeper
echo -n "$ZOOKEEPER_ID" > /var/lib/zookeeper/myid
set -x
./${zk_dir}/bin/zkServer.sh --config ./${conf_dir} start-foreground
# this point is never reached
_log "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment