#!/bin/bash if [ "$START_PERF_ANALYZER" = "false" ]; then echo "Not starting performance-analyzer-agent" exit 0 fi if [ -z "$1" ]; then if [ -z "$OPENSEARCH_HOME" ]; then echo "OPENSEARCH_HOME needs to be set or passed in as the first parameter." exit 1 fi else OPENSEARCH_HOME=$1 fi if [ ! -z "$2" ]; then JAVA_HOME=$2 elif [ ! -z "$OPENSEARCH_JAVA_HOME" ]; then # Use OPENSEARCH_JAVA_HOME if present JAVA_HOME=$OPENSEARCH_JAVA_HOME elif [ -z "$JAVA_HOME" ]; then # Nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is present, failing echo "OPENSEARCH_JAVA_HOME / JAVA_HOME needs to be set or passed in as the second parameter." exit 1 fi echo "Using JAVA_HOME: $JAVA_HOME" export JAVA_HOME=$JAVA_HOME # Instead of the supervisor executing performance-analyzer-agent from the plugin location, # we should move this to the reader. The entry-point script should be executing # performance-analyzer-agent from the reader location. # We need to change this file: https://github.com/opensearch-project/opensearch-build/blob/main/release/docker/config/opensearch/opensearch-docker-entrypoint.sh if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' >/dev/null; then export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-3.0.0-SNAPSHOT/config/log4j2.xml exec $OPENSEARCH_HOME/performance-analyzer-rca-3.0.0-SNAPSHOT/bin/performance-analyzer-rca else echo 'Starting deamon' export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-3.0.0-SNAPSHOT/config/log4j2.xml exec $OPENSEARCH_HOME/performance-analyzer-rca-3.0.0-SNAPSHOT/bin/performance-analyzer-rca & pid=$! PID_LOC=/tmp/performance-analyzer-agent if [ -n "$4" ]; then PID_LOC=$4 fi if ! ps -p $pid >$PID_LOC; then exit 1 fi fi