|
|
|
|
@ -17,12 +17,10 @@
@@ -17,12 +17,10 @@
|
|
|
|
|
package org.springframework.boot; |
|
|
|
|
|
|
|
|
|
import java.lang.management.ManagementFactory; |
|
|
|
|
import java.net.InetAddress; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.util.concurrent.Callable; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
import org.springframework.aot.AotDetector; |
|
|
|
|
import org.springframework.boot.system.ApplicationHome; |
|
|
|
|
@ -42,10 +40,6 @@ import org.springframework.util.StringUtils;
@@ -42,10 +40,6 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
*/ |
|
|
|
|
class StartupInfoLogger { |
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(StartupInfoLogger.class); |
|
|
|
|
|
|
|
|
|
private static final long HOST_NAME_RESOLVE_THRESHOLD = 200; |
|
|
|
|
|
|
|
|
|
private final Class<?> sourceClass; |
|
|
|
|
|
|
|
|
|
StartupInfoLogger(Class<?> sourceClass) { |
|
|
|
|
@ -71,7 +65,6 @@ class StartupInfoLogger {
@@ -71,7 +65,6 @@ class StartupInfoLogger {
|
|
|
|
|
appendApplicationName(message); |
|
|
|
|
appendVersion(message, this.sourceClass); |
|
|
|
|
appendJavaVersion(message); |
|
|
|
|
appendOn(message); |
|
|
|
|
appendPid(message); |
|
|
|
|
appendContext(message); |
|
|
|
|
return message; |
|
|
|
|
@ -116,26 +109,6 @@ class StartupInfoLogger {
@@ -116,26 +109,6 @@ class StartupInfoLogger {
|
|
|
|
|
append(message, "v", () -> source.getPackage().getImplementationVersion()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void appendOn(StringBuilder message) { |
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
append(message, "on ", () -> InetAddress.getLocalHost().getHostName()); |
|
|
|
|
long resolveTime = System.currentTimeMillis() - startTime; |
|
|
|
|
if (resolveTime > HOST_NAME_RESOLVE_THRESHOLD) { |
|
|
|
|
logger.warn(LogMessage.of(() -> { |
|
|
|
|
StringBuilder warning = new StringBuilder(); |
|
|
|
|
warning.append("InetAddress.getLocalHost().getHostName() took "); |
|
|
|
|
warning.append(resolveTime); |
|
|
|
|
warning.append(" milliseconds to respond."); |
|
|
|
|
warning.append(" Please verify your network configuration"); |
|
|
|
|
if (System.getProperty("os.name").toLowerCase().contains("mac")) { |
|
|
|
|
warning.append(" (macOS machines may need to add entries to /etc/hosts)"); |
|
|
|
|
} |
|
|
|
|
warning.append("."); |
|
|
|
|
return warning; |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void appendPid(StringBuilder message) { |
|
|
|
|
append(message, "with PID ", ApplicationPid::new); |
|
|
|
|
} |
|
|
|
|
|