mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 06:18:12 +00:00
availability checks now return non-2XX response code if unavailable; status script adjusted;
the java/target/status script now uses the consolidated /sailingserver/api/v1/status end point and returns a 200 response if and only if the RacingEventService has loaded all races it needs to load and replication reports availability. In all other cases, non-2XX codes are reported, such as 503 (not available) or 404 (not found) Change-Id: I55ca3c98de993be0e6fff8e02837d17dd54431f6
This commit is contained in:
1 parent
9968b239e6
commit
17093b4dc6
3 files changed
+17
-10
No files matched your search
+6
-3
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.server.gateway.jaxrs.api;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
@@ -27,8 +28,10 @@ public class StatusResource extends AbstractSailingServerResource {
|
||||
if (replicationStatus != null) {
|
||||
result.put("replication", replicationStatus.toJSONObject());
|
||||
}
|
||||
result.put("available", service.getNumberOfTrackedRacesRestored() >= service.getNumberOfTrackedRacesToRestore() &&
|
||||
(replicationStatus == null || replicationStatus.isAvailable()));
|
||||
return Response.ok(result.toJSONString()).header("Content-Type", MediaType.APPLICATION_JSON + ";charset=UTF-8").build();
|
||||
final boolean available = service.getNumberOfTrackedRacesRestored() >= service.getNumberOfTrackedRacesToRestore() &&
|
||||
(replicationStatus == null || replicationStatus.isAvailable());
|
||||
result.put("available", available);
|
||||
return Response.status(available ? HttpServletResponse.SC_OK : HttpServletResponse.SC_SERVICE_UNAVAILABLE).
|
||||
entity(result.toJSONString()).header("Content-Type", MediaType.APPLICATION_JSON + ";charset=UTF-8").build();
|
||||
}
|
||||
}
|
||||
@@ -212,6 +212,11 @@ public class ReplicationServlet extends AbstractHttpServlet {
|
||||
result.put("available", status.isAvailable());
|
||||
resp.setContentType("application/json;charset=UTF-8");
|
||||
resp.getWriter().print(result.toJSONString());
|
||||
if (status.isAvailable()) {
|
||||
resp.setStatus(HttpServletResponse.SC_OK);
|
||||
} else {
|
||||
resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-7
@@ -27,15 +27,14 @@ echo "JAVA_HOME: $JAVA_HOME"
|
||||
echo "INSTANCE_ID: $INSTANCE_ID"
|
||||
echo ""
|
||||
|
||||
RACING_EVENT_SERVICE_AVAILABLE=$(curl http://127.0.0.1:$SERVER_PORT/sailingserver/api/v1/status 2>/dev/null | jq .available)
|
||||
REPLICATION_AVAILABLE=$(curl http://127.0.0.1:$SERVER_PORT/replication/replication?action=STATUS 2>/dev/null | jq .available)
|
||||
INDEX_HTML_STATUS=$(curl -I http://127.0.0.1:8888/index.html 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
|
||||
STATUS=$(curl -i http://127.0.0.1:$SERVER_PORT/sailingserver/api/v1/status 2>/dev/null)
|
||||
RESPONSE_STATUS_CODE=$(echo $STATUS | head -n 1 | cut -d ' ' -f 2)
|
||||
|
||||
echo "RACING_EVENT_SERVICE_AVAILABLE: $RACING_EVENT_SERVICE_AVAILABLE"
|
||||
echo "REPLICATION_AVAILABLE: $REPLICATION_AVAILABLE"
|
||||
echo "INDEX_HTML_STATUS: $INDEX_HTML_STATUS"
|
||||
echo "AVAILABILITY_STATUS: $RESPONSE_STATUS_CODE"
|
||||
echo "AVAILABILITY_DETAILS:"
|
||||
echo "$STATUS" | grep "^\{" | jq .
|
||||
|
||||
if [[ $RACING_EVENT_SERVICE_AVAILABLE == "true" && $REPLICATION_AVAILABLE == "true" && $INDEX_HTML_STATUS =~ 2.. ]]; then
|
||||
if [[ $RESPONSE_STATUS_CODE =~ 2.. ]]; then
|
||||
echo "Server $SERVER_NAME is available on $SERVER_PORT"
|
||||
exit 0
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user