From 6f021ffb200a6f49b0a6bc47344a2edaeebe7f18 Mon Sep 17 00:00:00 2001 From: Ahoo Wang Date: Thu, 29 Apr 2021 00:20:26 +0800 Subject: [PATCH] optimize applicationDefaultJvmArgs for rest-api --- rest-api/build.gradle.kts | 18 +++++++++++++++++- rest-api/src/dist/config/application.yml | 6 ++++++ rest-api/src/dist/config/bootstrap.yml | 15 +++++++++++++++ rest-api/src/main/resources/bootstrap.yml | 4 ++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 rest-api/src/dist/config/application.yml create mode 100644 rest-api/src/dist/config/bootstrap.yml diff --git a/rest-api/build.gradle.kts b/rest-api/build.gradle.kts index 23c30f29..d47c7f27 100644 --- a/rest-api/build.gradle.kts +++ b/rest-api/build.gradle.kts @@ -2,11 +2,27 @@ plugins { application } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + application { - applicationDefaultJvmArgs = listOf("-Dspring.cloud.bootstrap.enabled=true") mainClass.set("me.ahoo.govern.rest.RestApiServer") + + applicationDefaultJvmArgs = listOf( + "-Xms512M", + "-Xmx512M", + "-server", + "-XX:+UseG1GC", + "-Xlog:gc*:file=logs/rest-api-gc.log:time,tags:filecount=10,filesize=100M", + "-Dspring.cloud.bootstrap.enabled=true", + "-Dspring.cloud.bootstrap.location=config/bootstrap.yml" + ) } + dependencies { implementation(platform(project(":dependencies"))) implementation("io.springfox:springfox-boot-starter") diff --git a/rest-api/src/dist/config/application.yml b/rest-api/src/dist/config/application.yml new file mode 100644 index 00000000..fea9fe5d --- /dev/null +++ b/rest-api/src/dist/config/application.yml @@ -0,0 +1,6 @@ +spring: + cloud: + govern: + discovery: + registry: + weight: 8 diff --git a/rest-api/src/dist/config/bootstrap.yml b/rest-api/src/dist/config/bootstrap.yml new file mode 100644 index 00000000..e0f145f4 --- /dev/null +++ b/rest-api/src/dist/config/bootstrap.yml @@ -0,0 +1,15 @@ +spring: + application: + name: govern-rest-api + cloud: + govern: + namespace: dev + config: + config-id: ${spring.application.name}.yml + redis: + mode: standalone + url: redis://localhost:6379 +logging: + file: + name: logs/${spring.application.name}.log + diff --git a/rest-api/src/main/resources/bootstrap.yml b/rest-api/src/main/resources/bootstrap.yml index 2f11fdbe..e0f145f4 100644 --- a/rest-api/src/main/resources/bootstrap.yml +++ b/rest-api/src/main/resources/bootstrap.yml @@ -9,3 +9,7 @@ spring: redis: mode: standalone url: redis://localhost:6379 +logging: + file: + name: logs/${spring.application.name}.log +