Commit 38b70859 authored by liaozan's avatar liaozan 🏀

Remove spring-boot-admin instead of micrometer-registry-prometheus

parent 534a4727
...@@ -17,8 +17,12 @@ public class IpAddressHolder { ...@@ -17,8 +17,12 @@ public class IpAddressHolder {
private static final String POD_IP = System.getenv("POD_IP"); private static final String POD_IP = System.getenv("POD_IP");
private static final String LOCAL_IP = Optional.ofNullable(findFirstNonLoopBackAddress()).map(InetAddress::getHostAddress).orElse("127.0.0.1"); private static final String LOCAL_IP = Optional.ofNullable(findFirstNonLoopBackAddress()).map(InetAddress::getHostAddress).orElse("127.0.0.1");
public static String getIpAddress() { public static String getLocalIp() {
return POD_IP == null ? LOCAL_IP : POD_IP; return getLocalIp(LOCAL_IP);
}
public static String getLocalIp(String fallback) {
return POD_IP == null ? fallback : POD_IP;
} }
private static InetAddress findFirstNonLoopBackAddress() { private static InetAddress findFirstNonLoopBackAddress() {
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
<pagehelper.version>5.3.3</pagehelper.version> <pagehelper.version>5.3.3</pagehelper.version>
<redisson.version>3.18.0</redisson.version> <redisson.version>3.18.0</redisson.version>
<skywalking-tooklit.version>9.0.0</skywalking-tooklit.version> <skywalking-tooklit.version>9.0.0</skywalking-tooklit.version>
<spring-boot-admin.version>2.7.11</spring-boot-admin.version>
<vavr.version>0.10.4</vavr.version> <vavr.version>0.10.4</vavr.version>
<xxl-job.version>2.0.2</xxl-job.version> <xxl-job.version>2.0.2</xxl-job.version>
<zookeeper.version>3.9.1</zookeeper.version> <zookeeper.version>3.9.1</zookeeper.version>
...@@ -423,16 +422,6 @@ ...@@ -423,16 +422,6 @@
<artifactId>apm-toolkit-logback-1.x</artifactId> <artifactId>apm-toolkit-logback-1.x</artifactId>
<version>${skywalking-tooklit.version}</version> <version>${skywalking-tooklit.version}</version>
</dependency> </dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<dependency> <dependency>
<groupId>io.vavr</groupId> <groupId>io.vavr</groupId>
<artifactId>vavr</artifactId> <artifactId>vavr</artifactId>
......
...@@ -127,7 +127,7 @@ public class JSONLoggingInitializer { ...@@ -127,7 +127,7 @@ public class JSONLoggingInitializer {
private String getCustomFields() { private String getCustomFields() {
JSONObject customFields = new JSONObject(); JSONObject customFields = new JSONObject();
customFields.set("appName", applicationName); customFields.set("appName", applicationName);
customFields.set("podIp", IpAddressHolder.getIpAddress()); customFields.set("podIp", IpAddressHolder.getLocalIp());
return customFields.toString(); return customFields.toString();
} }
......
...@@ -44,7 +44,7 @@ public class LoggingConfigLoadedEventListener extends ConfigLoadedEventListenerA ...@@ -44,7 +44,7 @@ public class LoggingConfigLoadedEventListener extends ConfigLoadedEventListenerA
* hostInfo properties, for logging pattern, used in logback-spring.xml * hostInfo properties, for logging pattern, used in logback-spring.xml
*/ */
private Map<String, Object> buildIpAddressProperties() { private Map<String, Object> buildIpAddressProperties() {
return Map.of("application.ipAddress", IpAddressHolder.getIpAddress()); return Map.of("application.ipAddress", IpAddressHolder.getLocalIp());
} }
/** /**
......
...@@ -15,7 +15,7 @@ public class XxlJobProperties implements ConfigurableProperties { ...@@ -15,7 +15,7 @@ public class XxlJobProperties implements ConfigurableProperties {
private String adminAddresses; private String adminAddresses;
private String ip = IpAddressHolder.getIpAddress(); private String ip = IpAddressHolder.getLocalIp();
private int port = -1; private int port = -1;
......
...@@ -24,20 +24,16 @@ ...@@ -24,20 +24,16 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>io.micrometer</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>micrometer-registry-prometheus</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
</dependency> </dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId> <artifactId>spring-boot-properties-migrator</artifactId>
......
package com.schbrain.framework.support.spring.admin;
import com.schbrain.common.util.IpAddressHolder;
import de.codecentric.boot.admin.client.config.InstanceProperties;
import de.codecentric.boot.admin.client.registration.ServletApplicationFactory;
import de.codecentric.boot.admin.client.registration.metadata.MetadataContributor;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
import javax.servlet.ServletContext;
/**
* @author liaozan
* @since 2023/10/26
*/
public class AdminApplicationFactory extends ServletApplicationFactory {
public AdminApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, ServletContext servletContext, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint, MetadataContributor metadataContributor,
DispatcherServletPath dispatcherServletPath) {
super(instance, management, server, servletContext, pathMappedEndpoints, webEndpoint, metadataContributor, dispatcherServletPath);
}
@Override
protected String getServiceHost() {
return IpAddressHolder.getIpAddress();
}
@Override
protected String getManagementHost() {
return IpAddressHolder.getIpAddress();
}
}
package com.schbrain.framework.support.spring.admin;
import de.codecentric.boot.admin.client.config.InstanceProperties;
import de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration;
import de.codecentric.boot.admin.client.registration.ApplicationFactory;
import de.codecentric.boot.admin.client.registration.metadata.MetadataContributor;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.context.annotation.Bean;
import javax.servlet.ServletContext;
/**
* @author liaozan
* @since 2023/10/26
*/
@AutoConfiguration(before = SpringBootAdminClientAutoConfiguration.class)
@ConditionalOnCloudPlatform(CloudPlatform.KUBERNETES)
public class SpringBootAdminFeatureAutoConfiguration {
@Bean
public ApplicationFactory applicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, ServletContext servletContext, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint, MetadataContributor metadataContributor,
DispatcherServletPath dispatcherServletPath) {
return new AdminApplicationFactory(instance, management, server, servletContext, pathMappedEndpoints, webEndpoint, metadataContributor, dispatcherServletPath);
}
}
...@@ -68,9 +68,6 @@ public class DefaultPropertiesEnvironmentPostProcessor extends LoggerAwareEnviro ...@@ -68,9 +68,6 @@ public class DefaultPropertiesEnvironmentPostProcessor extends LoggerAwareEnviro
defaultProperties.put("spring.main.allow-circular-references", true); defaultProperties.put("spring.main.allow-circular-references", true);
defaultProperties.put("spring.main.banner-mode", Banner.Mode.OFF.name()); defaultProperties.put("spring.main.banner-mode", Banner.Mode.OFF.name());
defaultProperties.put("server.shutdown", Shutdown.GRACEFUL.name()); defaultProperties.put("server.shutdown", Shutdown.GRACEFUL.name());
if (EnvUtils.runningOnCloudPlatform(environment)) {
defaultProperties.put("spring.boot.admin.client.url", "http://spring-boot-admin-server.devops:8019");
}
DefaultPropertiesPropertySource.addOrMerge(defaultProperties, environment.getPropertySources()); DefaultPropertiesPropertySource.addOrMerge(defaultProperties, environment.getPropertySources());
} }
......
com.schbrain.framework.support.spring.admin.SpringBootAdminFeatureAutoConfiguration
com.schbrain.framework.support.spring.elasticsearch.ElasticsearchFeatureAutoConfiguration com.schbrain.framework.support.spring.elasticsearch.ElasticsearchFeatureAutoConfiguration
com.schbrain.framework.support.spring.redisson.RedissonFeatureAutoConfiguration com.schbrain.framework.support.spring.redisson.RedissonFeatureAutoConfiguration
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment