Permalink
Browse files

Bin scripts pass through java options, avoid -XX opts.

This should improve portability and make it easier for
users to deploy with optimizations.

riemann               ; Basic java -jar riemann.jar /default/config
riemann foo.config    ; Custom config file
riemann -a foo.config ; Aggressive options
riemann -a -Xmx512m   ; Add custom JVM options
  • Loading branch information...
1 parent 6b411ef commit 566e3b45d10d4300964e67febfc6dc3db2b55bc9 @aphyr aphyr committed Dec 4, 2012
Showing with 79 additions and 16 deletions.
  1. +40 −8 pkg/deb/riemann
  2. +39 −8 pkg/tar/riemann
View
@@ -1,9 +1,41 @@
#!/bin/bash
-if [ -z "$1" ]
-then
- config="/etc/riemann/riemann.config"
-else
- config=$1
-fi
-
-exec java -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -jar "/usr/lib/riemann/riemann.jar" "$config"
+
+JAR="/usr/lib/riemann/riemann.jar"
+CONFIG="/etc/riemann/riemann.config"
+AGGRESSIVE_OPTS="-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseCompressedOops"
+
+usage()
+{
+ cat << EOF
+usage: $0 [-a] [java options ...] [config-file]
+
+Runs Riemann with the given configuration file.
+
+OPTIONS:
+ -h Show this message
+ -a Adds some default aggressive, nonportable JVM optimization flags.
+
+ Any unrecognized options (e.g. -XX:+UseParNewGC) will be passed on to java.
+EOF
+}
+
+OPTS=
+for arg in "$@"; do
+ case $arg in
+ "-a")
+ OPTS="$AGGRESSIVE_OPTS $OPTS"
+ ;;
+ "-h")
+ usage
+ exit 0
+ ;;
+ -*)
+ OPTS="$OPTS $arg"
+ ;;
+ *)
+ CONFIG="$arg"
+ ;;
+ esac
+done
+
+exec java $OPTS -jar "$JAR" "$CONFIG"
View
@@ -1,11 +1,42 @@
#!/bin/bash
top="$(dirname "$0")/.."
-if [ -z "$1" ]
-then
- config="$top/etc/riemann.config"
-else
- config=$1
-fi
-
-exec java -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -jar "$top/lib/riemann.jar" "$config"
+JAR="$top/lib/riemann.jar"
+CONFIG="$top/etc/riemann.config"
+AGGRESSIVE_OPTS="-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseCompressedOops"
+
+usage()
+{
+ cat << EOF
+usage: $0 [-a] [java options ...] [config-file]
+
+Runs Riemann with the given configuration file.
+
+OPTIONS:
+ -h Show this message
+ -a Adds some default aggressive, nonportable JVM optimization flags.
+
+ Any unrecognized options (e.g. -XX:+UseParNewGC) will be passed on to java.
+EOF
+}
+
+OPTS=
+for arg in "$@"; do
+ case $arg in
+ "-a")
+ OPTS="$AGGRESSIVE_OPTS $OPTS"
+ ;;
+ "-h")
+ usage
+ exit 0
+ ;;
+ -*)
+ OPTS="$OPTS $arg"
+ ;;
+ *)
+ CONFIG="$arg"
+ ;;
+ esac
+done
+
+exec java $OPTS -jar "$JAR" "$CONFIG"

0 comments on commit 566e3b4

Please sign in to comment.