# set java arguments such as memory allocation
JAVA_OPTS="-Xms5g -Xmx10g"
# to limit the number of worker threads, add " -Djava.util.concurrent.ForkJoinPool.common.parallelism=N" to JAVA_OPTS, where N is the desired number of threads; by default, the program uses all the available cores.

# check if this is a packaged version
IS_PACKAGED_VERSION='pyramid'
if [ "$IS_PACKAGED_VERSION" != "pyramid" ]; then
    cat >&2 << EOF
Error: You must build the project with Maven or download a pre-built package before you can run Pyramid. See 'Building from Source' in README.md or visit https://github.com/cheng-li/pyramid/releases to get a pre-built package.
EOF
    exit 1
fi

# determine pyramid home
SCRIPT="$0"
PYRAMID_HOME=`dirname "$SCRIPT"`
PYRAMID_HOME=`cd "$PYRAMID_HOME"; pwd`

# set class path
PYRAMID_CLASSPATH="$PYRAMID_HOME/lib/*"

# path containing the log4j2.xml file
LOG4J2="$PYRAMID_HOME/config/"

# run
exec java $JAVA_OPTS  -cp "$PYRAMID_CLASSPATH":"$LOG4J2"  \
                edu.neu.ccs.pyramid.application.AppLauncher $@

