Skip to content

Commit

Permalink
Packaging: Allow to configure ES_GC_LOG_FILE
Browse files Browse the repository at this point in the history
This deprecates the ES_USE_GC_LOGGING environment variable and adds
support to the packages for setting the ES_GC_LOG_FILE in
/etc/sysconfig and /etc/defaults

This is based on elastic#8479 by Andreas Kohn and just changes minor things
and removes ES_USE_GC_LOGGING
  • Loading branch information
spinscale committed Dec 12, 2014
1 parent 6bf1805 commit ef8bd13
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
8 changes: 4 additions & 4 deletions bin/elasticsearch
Expand Up @@ -96,7 +96,7 @@ if [ "x$ES_INCLUDE" = "x" ]; then
/usr/local/share/elasticsearch/elasticsearch.in.sh \
/opt/elasticsearch/elasticsearch.in.sh \
~/.elasticsearch.in.sh \
$ES_HOME/bin/elasticsearch.in.sh \
"$ES_HOME/bin/elasticsearch.in.sh" \
"`dirname "$0"`"/elasticsearch.in.sh; do
if [ -r "$include" ]; then
. "$include"
Expand Down Expand Up @@ -151,13 +151,13 @@ launch_service()
# The es-foreground option will tell Elasticsearch not to close stdout/stderr, but it's up to us not to daemonize.
if [ "x$daemonized" = "x" ]; then
es_parms="$es_parms -Des.foreground=yes"
exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
eval exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms "\"-Des.path.home=$ES_HOME\"" -cp "\"$ES_CLASSPATH\"" $props \
org.elasticsearch.bootstrap.Elasticsearch
# exec without running it in the background, makes it replace this shell, we'll never get here...
# no need to return something
else
# Startup Elasticsearch, background it, and write the pid.
exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
eval exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms "\"-Des.path.home=$ES_HOME\"" -cp "\"$ES_CLASSPATH\"" $props \
org.elasticsearch.bootstrap.Elasticsearch <&- &
return $?
fi
Expand Down Expand Up @@ -207,7 +207,7 @@ eval set -- "$args"
while true; do
case $1 in
-v)
"$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" $props \
eval "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS $es_parms "\"-Des.path.home=$ES_HOME\"" -cp "\"$ES_CLASSPATH\"" $props \
org.elasticsearch.Version
exit 0
;;
Expand Down
14 changes: 7 additions & 7 deletions bin/elasticsearch.in.bat
Expand Up @@ -63,12 +63,12 @@ set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly
REM When running under Java 7
REM JAVA_OPTS=%JAVA_OPTS% -XX:+UseCondCardMark

if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails
if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps
if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram
if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution
if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime
if NOT "%ES_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -Xloggc:%ES_HOME%/logs/gc.log
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime
if NOT "%ES_GC_LOG_FILE%" == "" set JAVA_OPTS=%JAVA_OPTS% -Xloggc:%ES_GC_LOG_FILE%

REM Causes the JVM to dump its heap on OutOfMemory.
set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
Expand All @@ -80,4 +80,4 @@ REM Disables explicit GC
set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC

set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/${project.build.finalName}.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/*
set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%"
set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%"
6 changes: 3 additions & 3 deletions bin/elasticsearch.in.sh
@@ -1,6 +1,6 @@
#!/bin/sh

ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*"

if [ "x$ES_MIN_MEM" = "x" ]; then
ES_MIN_MEM=256m
Expand Down Expand Up @@ -48,13 +48,13 @@ JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"

# GC logging options
if [ "x$ES_USE_GC_LOGGING" != "x" ]; then
if [ -n "$ES_GC_LOG_FILE" ]; then
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"
JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/elasticsearch/gc.log"
JAVA_OPTS="$JAVA_OPTS -Xloggc:$ES_GC_LOG_FILE"
fi

# Causes the JVM to dump its heap on OutOfMemory.
Expand Down
1 change: 1 addition & 0 deletions docs/reference/setup/as-a-service.asciidoc
Expand Up @@ -26,6 +26,7 @@ Each package features a configuration file, which allows you to set the followin
`CONF_FILE`:: Path to configuration file, defaults to `/etc/elasticsearch/elasticsearch.yml`
`ES_JAVA_OPTS`:: Any additional java options you may want to apply. This may be useful, if you need to set the `node.name` property, but do not want to change the `elasticsearch.yml` configuration file, because it is distributed via a provisioning system like puppet or chef. Example: `ES_JAVA_OPTS="-Des.node.name=search-01"`
`RESTART_ON_UPGRADE`:: Configure restart on package upgrade, defaults to `false`. This means you will have to restart your elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster.
`ES_GC_LOG_FILE` :: The absolute log file path for creating a garbage collection logfile, which is done by the JVM. Note that this logfile can grow pretty quick and thus is disabled by default.

[float]
==== Debian/Ubuntu
Expand Down
3 changes: 3 additions & 0 deletions src/deb/default/elasticsearch
Expand Up @@ -42,3 +42,6 @@

# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true

# Path to the GC log file
#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log
4 changes: 4 additions & 0 deletions src/deb/init.d/elasticsearch
Expand Up @@ -94,6 +94,9 @@ CONF_FILE=$CONF_DIR/elasticsearch.yml
# Maximum number of VMA (Virtual Memory Areas) a process can own
MAX_MAP_COUNT=262144

# Path to the GC log file
#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log

# End of variables that can be overwritten in $DEFAULT

# overwrite settings from default file
Expand All @@ -110,6 +113,7 @@ export ES_HEAP_SIZE
export ES_HEAP_NEWSIZE
export ES_DIRECT_SIZE
export ES_JAVA_OPTS
export ES_GC_LOG_FILE

# Check DAEMON exists
test -x $DAEMON || exit 0
Expand Down
1 change: 1 addition & 0 deletions src/rpm/init.d/elasticsearch
Expand Up @@ -41,6 +41,7 @@ export ES_HEAP_SIZE
export ES_HEAP_NEWSIZE
export ES_DIRECT_SIZE
export ES_JAVA_OPTS
export ES_GC_LOG_FILE
export JAVA_HOME

lockfile=/var/lock/subsys/$prog
Expand Down
3 changes: 3 additions & 0 deletions src/rpm/sysconfig/elasticsearch
Expand Up @@ -44,3 +44,6 @@ ES_USER=elasticsearch

# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true

# Path to the GC log file
#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log

0 comments on commit ef8bd13

Please sign in to comment.