Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/src/main/scripts/unixStartScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ cd "\$SAVED" >/dev/null
APP_NAME="${applicationName}"
APP_BASE_NAME=`basename "\$0"`

# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
DEFAULT_JVM_OPTS=${defaultJvmOpts}

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

Expand Down Expand Up @@ -105,6 +102,18 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

JAVA_VERSION=`"\$JAVA_HOME/bin/java" -version 2>&1 | fgrep version | cut -d' ' -f3 | tr -d '"' | cut -d. -f1`

# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
if [ "\$JAVA_VERSION" -ge 25 ]; then
DEFAULT_JVM_OPTS=@DEFAULT_JVM_OPTS_25@
elif [ "\$JAVA_VERSION" -ge 21 ]; then
DEFAULT_JVM_OPTS=${defaultJvmOpts}
else
echo "Java version must be at least 21"
exit 1
fi

# Increase the maximum file descriptors if we can.
if [ "\$cygwin" = "false" -a "\$darwin" = "false" -a "\$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
Expand Down
36 changes: 25 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,14 @@ run {
}
}

def tweakStartScript(createScriptTask) {
def tweakStartScript(createScriptTask, defaultJvmOpts25) {
def shortenWindowsClasspath = { line ->
line.replaceAll(/^set CLASSPATH=.*$/, "set CLASSPATH=%APP_HOME%/lib/*")
}

// this must be before the BESU_HOME replacement
createScriptTask.unixScript.text = createScriptTask.unixScript.text.replace('@DEFAULT_JVM_OPTS_25@', defaultJvmOpts25)

createScriptTask.unixScript.text = createScriptTask.unixScript.text.replace('BESU_HOME', '\$APP_HOME')
createScriptTask.windowsScript.text = createScriptTask.windowsScript.text.replace('BESU_HOME', '%~dp0..')

Expand All @@ -734,17 +737,28 @@ def tweakStartScript(createScriptTask) {
.join('\r\n')
}

def defaultJvmOpts21 = application.applicationDefaultJvmArgs + [
"-XX:MaxHeapFreeRatio=30",
"-XX:MinHeapFreeRatio=10",
"-XX:MaxGCPauseMillis=100",
"-XX:StartFlightRecording,settings=default.jfc",
"-Xlog:jfr*=off"
]

def defaultJvmOpts25 = defaultJvmOpts21 + [
"-XX:+UseCompactObjectHeaders"
]

def serializeDefaultJvmOpts(opts) {
return "'" + opts.collect{ /"$it"/}.join(' ') + "'"
}

startScripts {
defaultJvmOpts = application.applicationDefaultJvmArgs + [
"-XX:G1ConcRefinementThreads=2",
"-XX:G1HeapWastePercent=15",
"-XX:MaxGCPauseMillis=100",
"-XX:StartFlightRecording,settings=default.jfc",
"-Xlog:jfr*=off"
]
defaultJvmOpts = defaultJvmOpts21
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(startScripts) }

doLast { tweakStartScript(startScripts, serializeDefaultJvmOpts(defaultJvmOpts25)) }
}

task untunedStartScripts(type: CreateStartScripts) {
Expand All @@ -755,7 +769,7 @@ task untunedStartScripts(type: CreateStartScripts) {
defaultJvmOpts = application.applicationDefaultJvmArgs
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(untunedStartScripts) }
doLast { tweakStartScript(untunedStartScripts, serializeDefaultJvmOpts(application.applicationDefaultJvmArgs)) }
}

task evmToolStartScripts(type: CreateStartScripts) {
Expand All @@ -768,7 +782,7 @@ task evmToolStartScripts(type: CreateStartScripts) {
]
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(evmToolStartScripts) }
doLast { tweakStartScript(evmToolStartScripts, serializeDefaultJvmOpts(defaultJvmOpts)) }
}

task autocomplete(type: JavaExec) {
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

# Stage: Use Eclipse Temurin JRE
FROM eclipse-temurin:21-jre AS java-base
FROM eclipse-temurin:25-jre AS java-base

# Stage: Final Besu image
FROM ubuntu:24.04
Expand Down