Fix shutdown requests

This commit is contained in:
crschnick 2024-08-09 07:00:29 +00:00
parent dd7aa79fc4
commit 40e59ab6a0
4 changed files with 16 additions and 1 deletions

View file

@ -28,7 +28,8 @@ public class BeaconRequestHandler<T> implements HttpHandler {
@Override @Override
public void handle(HttpExchange exchange) { public void handle(HttpExchange exchange) {
if (OperationMode.isInShutdown()) { if (OperationMode.isInShutdown() && !beaconInterface.acceptInShutdown()) {
writeError(exchange, new BeaconClientErrorResponse("Daemon is currently in shutdown"), 400);
return; return;
} }

View file

@ -62,6 +62,10 @@ public abstract class BeaconInterface<T> {
return (Class<T>) Class.forName(name); return (Class<T>) Class.forName(name);
} }
public boolean acceptInShutdown() {
return false;
}
public boolean requiresCompletedStartup() { public boolean requiresCompletedStartup() {
return true; return true;
} }

View file

@ -12,6 +12,11 @@ import java.util.UUID;
public class AskpassExchange extends BeaconInterface<AskpassExchange.Request> { public class AskpassExchange extends BeaconInterface<AskpassExchange.Request> {
@Override
public boolean acceptInShutdown() {
return true;
}
@Override @Override
public String getPath() { public String getPath() {
return "/askpass"; return "/askpass";

View file

@ -11,6 +11,11 @@ import lombok.extern.jackson.Jacksonized;
public class HandshakeExchange extends BeaconInterface<HandshakeExchange.Request> { public class HandshakeExchange extends BeaconInterface<HandshakeExchange.Request> {
@Override
public boolean acceptInShutdown() {
return true;
}
@Override @Override
public String getPath() { public String getPath() {
return "/handshake"; return "/handshake";