ApplicationProperties appProps = context.getBean(ApplicationProperties.class);
ServerProperties serverProperties = context.getBean(ServerProperties.class);
AgentClient agentClient = context.getBean(AgentClient.class);
Service service = new Service();
service.setName(appProps.getId());
Integer port = serverProperties.getPort();
if (port == null) {
port = 8080;
}
service.setPort(port);
service.setTags(consulProperties.getTags());
//TODO: add support for Check
register(agentClient, service);
String managementPort = context.getEnvironment().getProperty("management.port", (String) null);
if (managementPort != null) {
Service management = new Service();
management.setName(appProps.getId() + "/management"); //TODO: configurable management suffix
management.setPort(Integer.parseInt(managementPort));
List<String> tags = new ArrayList<>(consulProperties.getTags());
tags.add("management"); //TODO: configurable management tag
management.setTags(tags);
register(agentClient, management);
}
if (!appProps.getRoutes().isEmpty()) {