Skip to content

Commit 28ca4ce

Browse files
committed
add java-tron.vmoption for configure jvm option
1 parent 30a3c85 commit 28ca4ce

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

framework/build.gradle

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ def binaryRelease(taskName, jarName, mainClass) {
208208
}
209209
}
210210
}
211-
startScripts {
212-
doLast {
213-
delete unixScript
214-
}
215-
}
211+
216212
def createScript(project, mainClass, name) {
217213
project.tasks.create(name: name, type: CreateStartScripts) {
218214
unixStartScriptGenerator.template = resources.text.fromFile('../gradle/unixStartScript.txt')
@@ -221,14 +217,14 @@ def createScript(project, mainClass, name) {
221217
mainClassName = mainClass
222218
applicationName = name
223219
classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtime
224-
defaultJvmOpts = ['-XX:+UseConcMarkSweepGC',
225-
'-XX:+PrintGCDetails',
226-
'-Xloggc:./gc.log',
227-
'-XX:+PrintGCDateStamps',
228-
'-XX:+CMSParallelRemarkEnabled',
229-
'-XX:ReservedCodeCacheSize=256m',
230-
'-XX:+CMSScavengeBeforeRemark'
231-
]
220+
// defaultJvmOpts = ['-XX:+UseConcMarkSweepGC',
221+
// '-XX:+PrintGCDetails',
222+
// '-Xloggc:./gc.log',
223+
// '-XX:+PrintGCDateStamps',
224+
// '-XX:+CMSParallelRemarkEnabled',
225+
// '-XX:ReservedCodeCacheSize=256m',
226+
// '-XX:+CMSScavengeBeforeRemark'
227+
// ]
232228
}
233229
project.tasks[name].dependsOn(project.jar)
234230
project.applicationDistribution.with {
@@ -238,7 +234,9 @@ def createScript(project, mainClass, name) {
238234
}
239235
}
240236
}
241-
237+
applicationDistribution.from("../gradle/java-tron.vmoptions") {
238+
into "bin"
239+
}
242240
//distZip {
243241
// doLast {
244242
// file("$destinationDir/$archiveName").renameTo("$destinationDir/"+'java-tron-'+version+'-bin.zip')

gradle/unixStartScript.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ cd "\$SAVED" >/dev/null
4343
APP_NAME="${applicationName}"
4444
APP_BASE_NAME=`basename "\$0"`
4545

46-
UNAME=\$(uname -s)
47-
if [ x"\$UNAME" == x"Linux" ];then
48-
TOTAL=\$(cat /proc/meminfo |grep MemTotal |awk -F ' ' '{print \$2}')
49-
MEM=\$(echo "\$TOTAL/1024/1024*0.8" | bc |awk -F. '{print \$1"g"}')
50-
JAVA_OPTS='"-Xmx\$MEM" "-Xms\$MEM"'
51-
fi
46+
#UNAME=\$(uname -s)
47+
#if [ x"\$UNAME" == x"Linux" ];then
48+
# TOTAL=\$(cat /proc/meminfo |grep MemTotal |awk -F ' ' '{print \$2}')
49+
# MEM=\$(echo "\$TOTAL/1024/1024*0.8" | bc |awk -F. '{print \$1"g"}')
50+
# JAVA_OPTS='"-Xmx\$MEM" "-Xms\$MEM"'
51+
#fi
5252

5353
# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
5454
DEFAULT_JVM_OPTS=${defaultJvmOpts}
55+
for line in \$(cat \$APP_HOME/bin/java-tron.vmoptions)
56+
do
57+
DEFAULT_JVM_OPTS="\$DEFAULT_JVM_OPTS \$line"
58+
done
5559

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

0 commit comments

Comments
 (0)