Skip to content

Commit 2a1343a

Browse files
wt0530githubgxll
authored andcommitted
[feat][dingo-dist] Embed JDK 17 into Dingo
1 parent 8c3cb91 commit 2a1343a

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

dingo-dist/bin/start-executor.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
2020
JAR_PATH=$(find $ROOT -name dingo-executor-*.jar)
2121
LOCAL_STORE_JAR_PATH=$(find $ROOT -name dingo-store-local*.jar)
2222
NET_JAR_PATH=$(find $ROOT -name dingo-net-*.jar)
23+
APP_HOME=$( cd "$( dirname "$0" )/.." && pwd )
24+
PLATFORM=$(uname -s)-$(uname -m | sed 's/x86_64/x64/')
2325
JAVA_OPTS="-Xms8g -Xmx8g -XX:+AlwaysPreTouch -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:+DisableExplicitGC -XX:+HeapDumpOnOutOfMemoryError -XX:MaxDirectMemorySize=4096m"
2426

25-
nohup java ${JAVA_OPTS} \
27+
EMBEDDED_JDK="${APP_HOME}/${PLATFORM}"
28+
if [ -d "${EMBEDDED_JDK}" ]; then
29+
export JAVA_HOME="${EMBEDDED_JDK}"
30+
PATH="${JAVA_HOME}/bin:${PATH}"
31+
fi
32+
33+
nohup ${JAVA_HOME}/bin/java ${JAVA_OPTS} \
2634
-Dlogback.configurationFile=file:${ROOT}/conf/logback-executor.xml \
2735
-classpath ${JAR_PATH}:${NET_JAR_PATH}:${LOCAL_STORE_JAR_PATH} \
2836
io.dingodb.server.executor.Starter \

dingo-dist/bin/start-web.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@
1818

1919
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
2020
JAR_PATH=$(find $ROOT -name dingo-web*.jar)
21+
APP_HOME=$( cd "$( dirname "$0" )/.." && pwd )
22+
PLATFORM=$(uname -s)-$(uname -m | sed 's/x86_64/x64/')
2123
JAVA_OPTS="-Xms1g -Xmx1g -XX:+AlwaysPreTouch -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:+DisableExplicitGC -XX:+HeapDumpOnOutOfMemoryError"
2224

23-
nohup java ${JAVA_OPTS} \
25+
EMBEDDED_JDK="${APP_HOME}/${PLATFORM}"
26+
if [ -d "${EMBEDDED_JDK}" ]; then
27+
export JAVA_HOME="${EMBEDDED_JDK}"
28+
PATH="${JAVA_HOME}/bin:${PATH}"
29+
fi
30+
31+
nohup ${JAVA_HOME}/bin/java ${JAVA_OPTS} \
2432
-Dlogback.configurationFile=file:${ROOT}/conf/logback-web.xml \
2533
-jar ${JAR_PATH} \
2634
--spring.config.location=${ROOT}/conf/application-web.yaml \

dingo-dist/build.gradle

+74-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,72 @@
1616

1717
plugins {
1818
id 'distribution'
19+
id 'de.undercouch.download' version '5.4.0'
20+
}
21+
22+
def jdkConfig = [
23+
'Linux-x64' : [
24+
url : 'https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz',
25+
dir : 'jdk-17.0.2+7'
26+
],
27+
'Windows-x64' : [
28+
url : 'https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_windows-x64_bin.zip',
29+
dir : 'jdk-17.0.2+7'
30+
],
31+
'Darwin-x64' : [
32+
url : 'https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_macos-x64_bin.tar.gz',
33+
dir : 'jdk-17.0.2+7/Contents/Home'
34+
]
35+
]
36+
37+
def down = project.hasProperty('isDownload') ? project.property('isDownload').toBoolean() : false
38+
39+
tasks.register('downloadJdk') {
40+
if (!down) {
41+
return
42+
}
43+
doLast {
44+
jdkConfig.each { platform, config ->
45+
def destFile = file("${buildDir}/jdk/${platform}.${config.url.split(/\./).last()}")
46+
def outputDir = file("${buildDir}/jdk/${platform}")
47+
48+
download.run {
49+
src config.url
50+
dest destFile
51+
overwrite false
52+
}
53+
54+
destFile.setReadable(true, false)
55+
destFile.setWritable(true)
56+
57+
mkdir(outputDir)
58+
outputDir.setWritable(true, false)
59+
60+
if (destFile.name.endsWith('.gz')) {
61+
copy {
62+
from tarTree(resources.gzip(destFile))
63+
into outputDir
64+
eachFile { fcd ->
65+
fcd.path = fcd.path.replaceFirst(/^[^\/]+\//, '')
66+
}
67+
includeEmptyDirs = false
68+
}
69+
} else if (destFile.name.endsWith('.zip')) {
70+
copy {
71+
from zipTree(destFile)
72+
into outputDir
73+
eachFile { fcd ->
74+
fcd.path = fcd.path.replaceFirst(/^[^\/]+\//, '')
75+
}
76+
includeEmptyDirs = false
77+
}
78+
}
79+
fileTree(outputDir).each { file ->
80+
file.setReadable(true, false)
81+
file.setExecutable(true, false)
82+
}
83+
}
84+
}
1985
}
2086

2187
task copyDepends(type: Copy) {
@@ -26,6 +92,13 @@ task copyDepends(type: Copy) {
2692
}
2793
into layout.projectDirectory.dir("dingo")
2894

95+
from(fileTree("${buildDir}/jdk")) {
96+
include('*-x64/**')
97+
exclude('*.gz')
98+
exclude('*.zip')
99+
}
100+
into layout.projectDirectory.dir("dingo")
101+
29102
from(project(':dingo-executor').layout.buildDirectory) {
30103
include('libs/dingo-executor-*-all.jar')
31104
}
@@ -70,7 +143,7 @@ task copyDepends(type: Copy) {
70143
}
71144

72145
tasks.register('packageDistribution', Zip) {
73-
dependsOn(copyDepends)
146+
dependsOn(copyDepends, downloadJdk)
74147
archiveFileName = "dingo.zip"
75148
destinationDirectory = layout.buildDirectory.dir('distributions')
76149
from layout.projectDirectory.dir("dingo")

0 commit comments

Comments
 (0)