hdata 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. set -e
  3. CDPATH=""
  4. SCRIPT="$0"
  5. while [ -h "$SCRIPT" ] ; do
  6. ls=$(ls -ld "$SCRIPT")
  7. link=$(expr "$ls" : '.*-> \(.*\)$')
  8. if expr "$link" : '/.*' > /dev/null; then
  9. SCRIPT="$link"
  10. else
  11. SCRIPT=$(dirname "$SCRIPT")/"$link"
  12. fi
  13. done
  14. HDATA_HOME=$(cd "$(dirname "$SCRIPT")/.."; pwd)
  15. HDATA_LIB_DIR=$HDATA_HOME/lib
  16. HDATA_CONF_DIR=$HDATA_HOME/conf
  17. if [ -x "$JAVA_HOME/bin/java" ]; then
  18. JAVA="$JAVA_HOME/bin/java"
  19. else
  20. JAVA=$(which java)
  21. fi
  22. if [ ! -x "$JAVA" ]; then
  23. echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
  24. exit 1
  25. fi
  26. HDATA_CLASSPATH_APPEND="$HDATA_CLASSPATH"
  27. HDATA_CLASSPATH='.'
  28. for f in $HDATA_LIB_DIR/*.jar; do
  29. HDATA_CLASSPATH="${HDATA_CLASSPATH}:$f";
  30. done
  31. if [ ! -z "$HDATA_CLASSPATH_APPEND" ]; then
  32. HDATA_CLASSPATH="${HDATA_CLASSPATH}:$HDATA_CLASSPATH_APPEND";
  33. fi
  34. JAVA_OPTS="$JAVA_OPTS -Xss256k"
  35. JAVA_OPTS="$JAVA_OPTS -Xms1G -Xmx1G -Xmn512M"
  36. JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
  37. JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
  38. JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"
  39. JAVA_OPTS="$JAVA_OPTS -XX:+CMSParallelRemarkEnabled"
  40. JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
  41. JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
  42. JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
  43. JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
  44. JAVA_OPTS="$JAVA_OPTS -XX:SoftRefLRUPolicyMSPerMB=0"
  45. JAVA_OPTS="$JAVA_OPTS -Dhdata.conf.dir=$HDATA_CONF_DIR"
  46. JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:///$HDATA_CONF_DIR/log4j2.xml"
  47. MAIN_CLASS="com.github.stuxuhai.hdata.CliDriver"
  48. exec "$JAVA" $JAVA_OPTS -cp "$HDATA_CLASSPATH" $MAIN_CLASS "$@"