#!/usr/bin/env bash set -e CDPATH="" SCRIPT="$0" while [ -h "$SCRIPT" ] ; do ls=$(ls -ld "$SCRIPT") link=$(expr "$ls" : '.*-> \(.*\)$') if expr "$link" : '/.*' > /dev/null; then SCRIPT="$link" else SCRIPT=$(dirname "$SCRIPT")/"$link" fi done HDATA_HOME=$(cd "$(dirname "$SCRIPT")/.."; pwd) HDATA_LIB_DIR=$HDATA_HOME/lib HDATA_CONF_DIR=$HDATA_HOME/conf if [ -x "$JAVA_HOME/bin/java" ]; then JAVA="$JAVA_HOME/bin/java" else JAVA=$(which java) fi if [ ! -x "$JAVA" ]; then echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" exit 1 fi HDATA_CLASSPATH_APPEND="$HDATA_CLASSPATH" HDATA_CLASSPATH='.' for f in $HDATA_LIB_DIR/*.jar; do HDATA_CLASSPATH="${HDATA_CLASSPATH}:$f"; done if [ ! -z "$HDATA_CLASSPATH_APPEND" ]; then HDATA_CLASSPATH="${HDATA_CLASSPATH}:$HDATA_CLASSPATH_APPEND"; fi JAVA_OPTS="$JAVA_OPTS -Xss256k" JAVA_OPTS="$JAVA_OPTS -Xms1G -Xmx1G -Xmn512M" JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC" JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC" JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled" JAVA_OPTS="$JAVA_OPTS -XX:+CMSParallelRemarkEnabled" JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC" JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75" JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly" JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" JAVA_OPTS="$JAVA_OPTS -XX:SoftRefLRUPolicyMSPerMB=0" JAVA_OPTS="$JAVA_OPTS -Dhdata.conf.dir=$HDATA_CONF_DIR" JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:///$HDATA_CONF_DIR/log4j2.xml" MAIN_CLASS="com.github.stuxuhai.hdata.CliDriver" exec "$JAVA" $JAVA_OPTS -cp "$HDATA_CLASSPATH" $MAIN_CLASS "$@"