Skip to content

Commit

Permalink
Improve health information.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Dec 14, 2020
1 parent 9992239 commit 5297710
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 328 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Proteus Changelog.
## Unreleased
### No issue

**Removed swagger module and updated dependencies.**


[999223901c55f4c](https://github.com/noboomu/proteus/commit/999223901c55f4c) Joshua Bauer *2020-11-20 21:38:54*

**Async service timeouts.**


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sinistral.proteus;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.util.concurrent.MoreExecutors;
Expand Down Expand Up @@ -244,12 +245,17 @@ public void failure(Service service)

undertow.start();

Duration timeout = config.getDuration("application.services.timeout");

try
{
serviceManager.startAsync().awaitHealthy(config.getDuration("application.services.timeout"));
} catch( Exception e )
serviceManager.startAsync().awaitHealthy(timeout);
} catch( TimeoutException e )
{
log.error("Failed start to services within {} minutes",timeout,e);
} catch (Exception e)
{
log.error("Failed start to services within 2 minutes",e);
log.error("Failed to start services",e);
}

// serviceManager.startAsync();
Expand Down Expand Up @@ -477,7 +483,15 @@ public ProteusApplication addDefaultRoutes(RoutingHandler router)
router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
exchange.getResponseSender().send("OK");

if(this.serviceManager.servicesByState().values().stream().allMatch(Service::isRunning))
{
exchange.setStatusCode(200).getResponseSender().send("OK");
}
else
{
exchange.setStatusCode(500).getResponseSender().send("NOT_HEALTHY");
}
});

this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());
Expand Down Expand Up @@ -687,4 +701,6 @@ public void printStatus()
log.info(sb.toString());
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.sinistral.proteus.protocol;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class HealthSummary {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
*/
package io.sinistral.proteus.server.endpoints;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.undertow.util.HttpString;

/**
* @author jbauer
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EndpointInfo implements Comparable<EndpointInfo>
{
private String consumes = "*/*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ protected void startUp() throws Exception





}


Expand Down
Loading

0 comments on commit 5297710

Please sign in to comment.