Skip to content

Commit

Permalink
longer start, check kafka, too (#97)
Browse files Browse the repository at this point in the history
* longer start, check kafka, too

Signed-off-by: Erin Schnabel <[email protected]>
  • Loading branch information
Erin Schnabel authored and BarDweller committed Sep 12, 2017
1 parent 1a71173 commit f8a4bb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions map-app/src/main/java/org/gameontext/map/Kafka.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class Kafka {
public Kafka(){
}

public boolean isHealthy() {
return producer != null;
}

private boolean multipleHosts(){
//this is a cheat, we need to enable ssl when talking to message hub, and not to kafka locally
//the easiest way to know which we are running on, is to check how many hosts are in kafkaUrl
Expand Down
5 changes: 4 additions & 1 deletion map-app/src/main/java/org/gameontext/map/MapResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class MapResource {
@Inject
protected MapRepository mapRepository;

@Inject
Kafka kafka;

@GET
public Response basicGet() {
return Response.ok().build();
Expand All @@ -48,7 +51,7 @@ public Response basicGet() {
@io.swagger.annotations.ApiOperation(value = "Check application health",
notes = "")
public Response healthCheck() {
if ( mapRepository != null && mapRepository.connectionReady() ) {
if ( mapRepository != null && mapRepository.connectionReady() && kafka.isHealthy() ) {
return Response.ok().entity("{\"status\":\"UP\"}").build();
} else {
return Response.status(Status.SERVICE_UNAVAILABLE).entity("{\"status\":\"DOWN\"}").build();
Expand Down
3 changes: 2 additions & 1 deletion map-wlpcfg/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ADD ./servers/gameon-map /opt/ibm/wlp/usr/servers/defaultServer/

CMD ["/opt/startup.sh"]

# Generous start time for constrained systems
HEALTHCHECK \
--timeout=10s \
--start-period=40s \
--start-period=2m \
CMD wget -q -O /dev/null http://localhost:9080/map/v1/health

0 comments on commit f8a4bb0

Please sign in to comment.