forked from tjake/Jlama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-cli.sh
executable file
·43 lines (36 loc) · 1.67 KB
/
run-cli.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
#!/bin/bash
# Function to extract the major version of Java
get_java_major_version() {
local version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo ${version%%.*}
}
# Verify Java version is JDK 21
JAVA_MAJOR_VERSION=$(get_java_major_version)
if [[ "$JAVA_MAJOR_VERSION" != "21" ]]; then
echo "Error: JDK 21 is required to run this application."
exit 1
fi
# Define the path of the relative JAR
JLAMA_RELATIVE_JAR="./jlama-cli/target/jlama-cli.jar"
# Path to the logback.xml
LOGBACK_CONFIG="./conf/logback.xml"
JLAMA_JVM_ARGS="-server -Dstdout.encoding=UTF-8 -Xmx12g -Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=0 --add-modules=jdk.incubator.vector --add-exports java.base/sun.nio.ch=ALL-UNNAMED --enable-preview --enable-native-access=ALL-UNNAMED \
-XX:+UnlockDiagnosticVMOptions -XX:CompilerDirectivesFile=./inlinerules.json -XX:+AlignVector -XX:+UseStringDeduplication \
-XX:+UseCompressedOops -XX:+UseCompressedClassPointers "
# Check if PREINSTALLED_JAR environment variable is set
if [[ -z "$JLAMA_PREINSTALLED_JAR" ]]; then
# If the relative JAR doesn't exist, build it
if [[ ! -f $JLAMA_RELATIVE_JAR ]]; then
echo "The JAR $JLAMA_RELATIVE_JAR is missing. Attempting to build..."
./mvnw clean package -DskipTests
if [[ $? -ne 0 ]]; then
echo "Error building the JAR. Please check your build setup."
exit 1
fi
fi
# Run the JAR in a relative directory
java $JLAMA_JVM_ARGS $JLAMA_JVM_ARGS_EXTRA -Dlogback.configurationFile=$LOGBACK_CONFIG -jar $JLAMA_RELATIVE_JAR "$@"
else
# If PREINSTALLED_JAR is set, run the JAR specified by the variable
java $JLAMA_JVM_ARGS $JLAMA_JVM_ARGS_EXTRA -jar $JLAMA_PREINSTALLED_JAR "$@"
fi