Skip to content

Commit

Permalink
add support of JAVA_HOME environment
Browse files Browse the repository at this point in the history
fix find in root directory(/) when use in systemd
  • Loading branch information
therb1 authored and adejanovski committed Mar 23, 2020
1 parent cb81b63 commit b970844
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/packaging/bin/cassandra-reaper
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

REAPER_JAR=$(find . -maxdepth 4 -regex '.*/cassandra-reaper-.*[0-9rT]\.jar')
REAPER_JAR=$(find /usr/share/cassandra-reaper/ -maxdepth 4 -regex '.*/cassandra-reaper-.*[0-9rT]\.jar')

if [ $REAPER_JAR ]; then
echo "Using reaper in target"
Expand All @@ -36,6 +36,28 @@ else
CONFIG_PATH="$@"
fi

# Use JAVA_HOME if set, otherwise look for java in PATH
if [ -n "$JAVA_HOME" ]; then
# Why we can't have nice things: Solaris combines x86 and x86_64
# installations in the same tree, using an unconventional path for the
# 64bit JVM. Since we prefer 64bit, search the alternate path first,
# (see https://issues.apache.org/jira/browse/CASSANDRA-4638).
for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
if [ -x "$java" ]; then
JAVA="$java"
break
fi
done
else
JAVA=java
fi

if [ -z $JAVA ] ; then
echo Unable to find java executable. Check JAVA_HOME and PATH environment variables. >&2
exit 1;
fi


JVM_OPTS=(
# it is safe and performant to disable assertions in production environments (ie replace `-ea` with `-da`)
-ea
Expand All @@ -47,7 +69,7 @@ JVM_OPTS=(
-Djava.net.preferIPv4Stack=true
)

exec java ${JVM_OPTS[@]} \
exec ${JAVA} ${JVM_OPTS[@]} \
-cp ${CLASS_PATH} \
io.cassandrareaper.ReaperApplication \
server ${CONFIG_PATH}

0 comments on commit b970844

Please sign in to comment.