Skip to content

Commit

Permalink
make the LS_JAVA_OPTS environment variable available to the client si…
Browse files Browse the repository at this point in the history
…de, so the user is not force to use the default ones and they can rewrite it

remove stale code

cleanup the bash conditions for when a variable is defined or not

make sure LS_JAVA_OPTS override JAVA_OPTS when need

ammend unused var

rollback to previous use case of appending vars to JAVA_OPTS in the case of having LS_JAVA_OPTS

Fixes elastic#2942
  • Loading branch information
Pere Urbon-Bayes authored and jordansissel committed Apr 17, 2015
1 parent cbb225d commit cbaadb1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
27 changes: 19 additions & 8 deletions bin/logstash.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,26 @@ setup_java() {
exit 1
fi

JAVA_OPTS="$JAVA_OPTS -Xmx${LS_HEAP_SIZE}"
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
if [ "$LS_HEAP_SIZE" ] ; then
JAVA_OPTS="$JAVA_OPTS -Xmx${LS_HEAP_SIZE}"
fi

if [ -z "$LS_JAVA_OPTS" ] ; then
# There are no JAVA_OPTS set from the client, we set a predefined
# set of options that think are good in general
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"

JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
else
# The client set the variable LS_JAVA_OPTS, choosing his own
# set of java opts.
JAVA_OPTS="$JAVA_OPTS $LS_JAVA_OPTS"
fi

if [ ! -z "$LS_USE_GC_LOGGING" ] ; then
if [ "$LS_USE_GC_LOGGING" ] ; then
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram"
Expand Down Expand Up @@ -96,7 +107,7 @@ jruby_opts() {
setup() {
# first check if we want to use drip, which can be used in vendored jruby mode
# and also when setting USE_RUBY=1 if the ruby interpretor is in fact jruby
if [ ! -z "$JAVACMD" ] ; then
if [ "$JAVACMD" ] ; then
if [ "$(basename $JAVACMD)" = "drip" ] ; then
DRIP_JAVACMD=1
USE_DRIP=1
Expand Down
7 changes: 4 additions & 3 deletions pkg/logstash.sysv
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ LS_USER=logstash
LS_GROUP=logstash
LS_HOME=/var/lib/logstash
LS_HEAP_SIZE="500m"
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
LS_LOG_DIR=/var/log/logstash
LS_LOG_FILE="${LS_LOG_DIR}/$name.log"
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
LS_NICE=19
LS_OPTS=""


[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

Expand All @@ -46,8 +46,9 @@ args="agent -f ${LS_CONF_DIR} -l ${LS_LOG_FILE} ${LS_OPTS}"

start() {


JAVA_OPTS=${LS_JAVA_OPTS}
# Set JAVA_OPTS to avoid sharing configuration between other
# JVM based programs running on the same time
JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
HOME=${LS_HOME}
export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING

Expand Down
5 changes: 3 additions & 2 deletions pkg/logstash.sysv.debian
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ LS_USER=logstash
LS_GROUP=logstash
LS_HOME=/var/lib/logstash
LS_HEAP_SIZE="500m"
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
LS_LOG_FILE=/var/log/logstash/$NAME.log
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
Expand Down Expand Up @@ -85,7 +84,9 @@ case "$1" in
>/dev/null; then
# Prepare environment
HOME="${HOME:-$LS_HOME}"
JAVA_OPTS="${LS_JAVA_OPTS}"
# Set JAVA_OPTS to avoid sharing configuration between other
# JVM based programs running on the same time
JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
ulimit -n ${LS_OPEN_FILES}
cd "${LS_HOME}"
export PATH HOME JAVACMD JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
Expand Down
5 changes: 3 additions & 2 deletions pkg/logstash.sysv.redhat
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ LS_USER=logstash
LS_GROUP=logstash
LS_HOME=/var/lib/logstash
LS_HEAP_SIZE="500m"
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
LS_LOG_FILE=/var/log/logstash/$NAME.log
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
Expand Down Expand Up @@ -73,7 +72,9 @@ do_start()

# Prepare environment
HOME="${HOME:-$LS_HOME}"
JAVA_OPTS="${LS_JAVA_OPTS}"
# Set JAVA_OPTS to avoid sharing configuration between other
# JVM based programs running on the same time
JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
ulimit -n ${LS_OPEN_FILES}
cd "${LS_HOME}"
export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
Expand Down
5 changes: 3 additions & 2 deletions pkg/logstash.upstart.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ script
PATH=/bin:/usr/bin
LS_HOME=/var/lib/logstash
LS_HEAP_SIZE="500m"
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
LS_LOG_FILE=/var/log/logstash/logstash.log
LS_USE_GC_LOGGING=""
LS_CONF_DIR=/etc/logstash/conf.d
Expand All @@ -35,7 +34,9 @@ script
[ -f /etc/default/logstash ] && . /etc/default/logstash

HOME="${HOME:-$LS_HOME}"
JAVA_OPTS="${LS_JAVA_OPTS}"
# Set JAVA_OPTS to avoid sharing configuration between other
# JVM based programs running on the same time
JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
# Reset filehandle limit
ulimit -n ${LS_OPEN_FILES}
cd "${LS_HOME}"
Expand Down

0 comments on commit cbaadb1

Please sign in to comment.