forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogstash.lib.sh
executable file
·85 lines (74 loc) · 2.44 KB
/
logstash.lib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
basedir=$(cd `dirname $0`/..; pwd)
setup_ruby() {
export RUBYLIB="$basedir/lib"
# Verify ruby works
if ! ruby -e 'puts "HURRAY"' 2> /dev/null | grep -q "HURRAY" ; then
echo "No ruby program found. Cannot start."
exit 1
fi
eval $(ruby -rrbconfig -e 'puts "RUBYVER=#{RbConfig::CONFIG["ruby_version"]}"; puts "RUBY=#{RUBY_ENGINE}"')
RUBYCMD="ruby"
export GEM_HOME="$basedir/vendor/bundle/${RUBY}/${RUBYVER}"
export GEM_PATH=
}
setup_java() {
if [ -z "$JAVACMD" ] ; then
if [ -z "$JAVA_HOME/bin/java" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD="java"
fi
elif [ "$(basename $JAVACMD)" = "drip" ] ; then
export DRIP_INIT_CLASS="org.jruby.main.DripMain"
export DRIP_INIT=
fi
if [ ! -x "$JAVACMD" ] ; then
JAVACMD="$(which $JAVACMD 2> /dev/null)"
if [ ! -x "$JAVACMD" ] ; then
echo "Could not find any executable java binary (tried '$JAVACMD'). Please install java in your PATH or set JAVA_HOME."
exit 1
fi
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"
JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
if [ ! -z "$LS_USE_GC_LOGGING" ] ; 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:./logstash-gc.log"
echo "Writing garbage collection logs to ./logstash-gc.log"
fi
export JAVACMD
export JAVA_OPTS
export RUBYLIB="$basedir/lib"
export GEM_HOME="$basedir/vendor/bundle/jruby/1.9"
export GEM_PATH=
}
setup_vendored_jruby() {
RUBYVER=1.9
RUBY=jruby
RUBYCMD="$JAVACMD $JAVA_OPTS -jar $basedir/vendor/jar/jruby-complete-*.jar"
}
setup() {
setup_java
if [ -z "$USE_JRUBY" -a \( -d "$basedir/.git" -o ! -z "$USE_RUBY" \) ] ; then
setup_ruby
else
setup_vendored_jruby
fi
}
install_deps() {
if [ -f "$basedir/logstash.gemspec" ] ; then
program="$basedir/gembag.rb"
set -- "$basedir/logstash.gemspec"
exec $RUBYCMD "$basedir/gembag.rb" "$@"
else
echo "Cannot install dependencies; missing logstash.gemspec. This 'deps' command only works from a logstash git clone."
fi
}