@Configuration(proxyBeanMethods = false)
@Slf4j
public class TomcatAutoConfiguration {
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> webServerFactoryCustomizer(ServerProperties serverProperties) {
return factory -> {
if (serverProperties.getUseUnixSocket()) {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
log.info("Unix system,use Unix socket");
factory.addConnectorCustomizers(connector -> connector.setProperty("unixDomainSocketPath", serverProperties.getSocketFile()));
}
}
};
}
}
The code above, when run using java -jar, will listen to a socket at the specified file path. However, after building it using native, the code still runs normally, but it actually listens to a port instead of a Unix socket file.
sprint boot version: 3.2.1 native-maven-plugin version: 0.9.28
Use Unix socket instead of http port as normal