2012-06-10 22:27:52 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-07-03 04:32:01 -04:00
|
|
|
CORE_CLASSPATH="$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*"
|
2015-07-02 13:16:20 -04:00
|
|
|
|
|
|
|
if [ "x$ES_CLASSPATH" = "x" ]; then
|
|
|
|
ES_CLASSPATH="$CORE_CLASSPATH"
|
|
|
|
else
|
|
|
|
ES_CLASSPATH="$ES_CLASSPATH:$CORE_CLASSPATH"
|
|
|
|
fi
|
2010-02-08 08:30:06 -05:00
|
|
|
|
2010-05-01 08:55:49 -04:00
|
|
|
if [ "x$ES_MIN_MEM" = "x" ]; then
|
2015-03-30 09:58:34 -04:00
|
|
|
ES_MIN_MEM=${packaging.elasticsearch.heap.min}
|
2010-05-01 08:55:49 -04:00
|
|
|
fi
|
|
|
|
if [ "x$ES_MAX_MEM" = "x" ]; then
|
2015-03-30 09:58:34 -04:00
|
|
|
ES_MAX_MEM=${packaging.elasticsearch.heap.max}
|
2010-05-01 08:55:49 -04:00
|
|
|
fi
|
2012-02-06 15:09:32 -05:00
|
|
|
if [ "x$ES_HEAP_SIZE" != "x" ]; then
|
|
|
|
ES_MIN_MEM=$ES_HEAP_SIZE
|
|
|
|
ES_MAX_MEM=$ES_HEAP_SIZE
|
|
|
|
fi
|
2010-05-01 08:55:49 -04:00
|
|
|
|
2010-11-22 20:51:38 -05:00
|
|
|
# min and max heap sizes should be set to the same value to avoid
|
|
|
|
# stop-the-world GC pauses during resize, and so that we can lock the
|
|
|
|
# heap in memory on startup to prevent any of it from being swapped
|
|
|
|
# out.
|
2010-08-13 18:10:36 -04:00
|
|
|
JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}"
|
2010-11-22 20:51:38 -05:00
|
|
|
|
2012-02-06 15:09:32 -05:00
|
|
|
# new generation
|
|
|
|
if [ "x$ES_HEAP_NEWSIZE" != "x" ]; then
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Xmn${ES_HEAP_NEWSIZE}"
|
|
|
|
fi
|
|
|
|
|
2012-07-31 09:06:21 -04:00
|
|
|
# max direct memory
|
|
|
|
if [ "x$ES_DIRECT_SIZE" != "x" ]; then
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=${ES_DIRECT_SIZE}"
|
|
|
|
fi
|
|
|
|
|
2012-06-14 07:14:03 -04:00
|
|
|
# set to headless, just in case
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
|
|
|
|
|
2011-09-22 17:57:57 -04:00
|
|
|
# Force the JVM to use IPv4 stack
|
2012-12-12 18:51:16 -05:00
|
|
|
if [ "x$ES_USE_IPV4" != "x" ]; then
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
|
|
|
|
fi
|
2011-09-22 17:57:57 -04:00
|
|
|
|
2010-08-13 18:10:36 -04:00
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
|
2012-02-06 15:11:22 -05:00
|
|
|
|
2010-10-15 12:26:38 -04:00
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
|
|
|
|
|
2012-12-12 18:51:16 -05:00
|
|
|
# GC logging options
|
2014-11-14 04:33:27 -05:00
|
|
|
if [ -n "$ES_GC_LOG_FILE" ]; then
|
2012-12-12 18:51:16 -05:00
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
|
2014-11-14 04:33:27 -05:00
|
|
|
JAVA_OPTS="$JAVA_OPTS \"-Xloggc:$ES_GC_LOG_FILE\""
|
|
|
|
|
|
|
|
# Ensure that the directory for the log file exists: the JVM will not create it.
|
|
|
|
mkdir -p "`dirname \"$ES_GC_LOG_FILE\"`"
|
2012-12-12 18:51:16 -05:00
|
|
|
fi
|
2011-01-07 09:59:50 -05:00
|
|
|
|
2010-11-22 20:51:38 -05:00
|
|
|
# Causes the JVM to dump its heap on OutOfMemory.
|
2010-08-13 18:10:36 -04:00
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
|
2010-11-22 20:51:38 -05:00
|
|
|
# The path to the heap dump location, note directory must exists and have enough
|
|
|
|
# space for a full heap dump.
|
|
|
|
#JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof"
|
2014-06-27 07:02:26 -04:00
|
|
|
|
|
|
|
# Disables explicit GC
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
|
2014-12-15 10:36:43 -05:00
|
|
|
|
|
|
|
# Ensure UTF-8 encoding by default (e.g. filenames)
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
|
2015-05-14 00:09:44 -04:00
|
|
|
|
|
|
|
# Use our provided JNA always versus the system one
|
|
|
|
JAVA_OPTS="$JAVA_OPTS -Djna.nosys=true"
|