diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/java/com/orion/visor/framework/banner/core/runner/BannerApplicationRunner.java b/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/java/com/orion/visor/framework/banner/core/runner/BannerApplicationRunner.java index ff716685..8f0bac68 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/java/com/orion/visor/framework/banner/core/runner/BannerApplicationRunner.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/java/com/orion/visor/framework/banner/core/runner/BannerApplicationRunner.java @@ -36,24 +36,47 @@ public class BannerApplicationRunner implements ApplicationRunner { @Value("${management.endpoints.web.base-path:''}") private String managementEndpoints; + @Value("${springdoc.api-docs.enabled}") + private Boolean apiDocsEnabled; + + @Value("${spring.datasource.druid.stat-view-servlet.enabled}") + private Boolean druidConsoleEnabled; + + @Value("#{'${management.endpoints.web.exposure.include}' != 'shutdown'}") + private Boolean springBootActuatorEnabled; + + @Value("${spring.boot.admin.client.enabled}") + private Boolean springBootAdminClientEnabled; + @Override public void run(ApplicationArguments args) { - String line = AnsiAppender.create() - .append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor-launch v" + version + " 服务已启动(" + env + ") ::\n") - .append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ") - .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/doc.html\n") - .append(AnsiForeground.BRIGHT_GREEN, ":: druid console ") - .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/druid/index.html\n") - .append(AnsiForeground.BRIGHT_GREEN, ":: actuator endpoint ") - .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + managementEndpoints + "\n") - .append(AnsiForeground.BRIGHT_GREEN, ":: admin console ") - .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + adminSeverContextPath + "\n") - .append(AnsiForeground.BRIGHT_GREEN, ":: server 健康检测 ") - .append(AnsiForeground.BRIGHT_BLUE, "curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"") - .toString(); + AnsiAppender appender = AnsiAppender.create() + .append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor-launch v" + version + " 服务已启动(" + env + ") ::\n"); + // swagger 地址 + if (apiDocsEnabled) { + appender.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ") + .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/doc.html\n"); + } + // druid 控制台 + if (druidConsoleEnabled) { + appender.append(AnsiForeground.BRIGHT_GREEN, ":: druid console ") + .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/druid/index.html\n"); + } + // admin actuator 端点 + if (springBootActuatorEnabled) { + appender.append(AnsiForeground.BRIGHT_GREEN, ":: actuator endpoint ") + .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + managementEndpoints + "\n"); + } + // admin server 控制台 + if (springBootAdminClientEnabled) { + appender.append(AnsiForeground.BRIGHT_GREEN, ":: admin console ") + .append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + adminSeverContextPath + "\n"); + } + appender.append(AnsiForeground.BRIGHT_GREEN, ":: server 健康检测 ") + .append(AnsiForeground.BRIGHT_BLUE, "curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\""); Threads.start(() -> { Threads.sleep(1000L); - System.out.println(line); + System.out.println(appender); }); } diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/resources/banner.txt b/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/resources/banner.txt index 415c802a..c46f2189 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/resources/banner.txt +++ b/orion-visor-framework/orion-visor-spring-boot-starter-banner/src/main/resources/banner.txt @@ -8,4 +8,5 @@ ${AnsiColor.BRIGHT_GREEN}:: Application Name ${AnsiColor.BLUE}${spring.appli ${AnsiColor.BRIGHT_GREEN}:: Application Version ${AnsiColor.BLUE}${orion.version} ${AnsiColor.BRIGHT_GREEN}:: SpringBoot Version ${AnsiColor.BLUE}${spring-boot.version} ${AnsiColor.BRIGHT_GREEN}:: Active Profile ${AnsiColor.BLUE}${spring.profiles.active} +${AnsiColor.BRIGHT_GREEN}:: Demo Mode ${AnsiColor.BLUE}${orion.demo} ${AnsiColor.DEFAULT} \ No newline at end of file diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-swagger/src/main/java/com/orion/visor/framework/swagger/configuration/OrionSwaggerAutoConfiguration.java b/orion-visor-framework/orion-visor-spring-boot-starter-swagger/src/main/java/com/orion/visor/framework/swagger/configuration/OrionSwaggerAutoConfiguration.java index 7881a95f..655d0e84 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-swagger/src/main/java/com/orion/visor/framework/swagger/configuration/OrionSwaggerAutoConfiguration.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-swagger/src/main/java/com/orion/visor/framework/swagger/configuration/OrionSwaggerAutoConfiguration.java @@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Profile; import org.springframework.http.HttpHeaders; import java.util.HashMap; @@ -38,10 +37,9 @@ import java.util.Optional; * @version 1.0.0 * @since 2022/6/21 11:22 */ -@Profile({"dev"}) @ConditionalOnClass({OpenAPI.class}) @EnableConfigurationProperties(SwaggerConfig.class) -@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true") @AutoConfiguration @AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SWAGGER) public class OrionSwaggerAutoConfiguration { diff --git a/orion-visor-launch/src/main/resources/application-dev.yaml b/orion-visor-launch/src/main/resources/application-dev.yaml index f0ffdc11..e50c9c13 100644 --- a/orion-visor-launch/src/main/resources/application-dev.yaml +++ b/orion-visor-launch/src/main/resources/application-dev.yaml @@ -7,6 +7,8 @@ spring: initial-size: 0 min-idle: 1 max-active: 5 + stat-view-servlet: + enabled: false redis: host: 127.0.0.1 port: 6379 @@ -15,6 +17,19 @@ spring: threads: 2 netty-threads: 2 minimum-idle-size: 2 + boot: + admin: + client: + enabled: false + server: + enabled: false + +management: + endpoints: + enabled-by-default: false + web: + exposure: + include: shutdown mybatis-plus: configuration: diff --git a/orion-visor-launch/src/main/resources/application-prod.yaml b/orion-visor-launch/src/main/resources/application-prod.yaml index c85e6402..284b6f82 100644 --- a/orion-visor-launch/src/main/resources/application-prod.yaml +++ b/orion-visor-launch/src/main/resources/application-prod.yaml @@ -10,10 +10,13 @@ spring: min-idle: 5 # 最大连接池数量 max-active: 20 - web-stat-filter: - enabled: true + # 控制台 stat-view-servlet: enabled: true + login-username: ${DRUID_USERNAME:admin} + login-password: ${DRUID_PASSWORD:admin} + web-stat-filter: + enabled: true filter: stat: enabled: true @@ -31,6 +34,16 @@ spring: quartz: threadPool: threadCount: 10 + boot: + admin: + client: + enabled: true + server: + enabled: true + +management: + endpoints: + enabled-by-default: true springdoc: api-docs: @@ -40,6 +53,7 @@ springdoc: knife4j: enable: false + production: true orion: # 是否为演示模式 diff --git a/orion-visor-launch/src/main/resources/application.yaml b/orion-visor-launch/src/main/resources/application.yaml index 52f229d1..d72dc6d1 100644 --- a/orion-visor-launch/src/main/resources/application.yaml +++ b/orion-visor-launch/src/main/resources/application.yaml @@ -40,13 +40,14 @@ spring: # 最大生存的时间 max-evictable-idle-time-millis: 900000 validation-query: SELECT 1 - web-stat-filter: - enabled: true + # 控制台 stat-view-servlet: enabled: true url-pattern: /druid/* login-username: login-password: + web-stat-filter: + enabled: true filter: stat: enabled: true @@ -88,7 +89,7 @@ spring: misfireThreshold: 60000 clusterCheckinInterval: 5000 isClustered: true - #连接池 + # 连接池 threadPool: class: org.quartz.simpl.SimpleThreadPool threadCount: 5 @@ -98,12 +99,16 @@ spring: admin: context-path: /admin client: + enabled: true url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} instance: service-host-type: IP + server: + enabled: true management: endpoints: + enabled-by-default: true web: base-path: /actuator exposure: