-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from mp-access/dev
Release v0.10.1
- Loading branch information
Showing
48 changed files
with
1,658 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ch.uzh.ifi.access; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@RestController | ||
public class ServerInfoController { | ||
|
||
private final ServerInfo serverInfo; | ||
|
||
public ServerInfoController(ServerInfo serverInfo) { | ||
this.serverInfo = serverInfo; | ||
} | ||
|
||
@GetMapping("/info") | ||
public ResponseEntity<?> info() { | ||
Map<String, String> response = new HashMap<>(); | ||
response.put("offsetDateTime", ZonedDateTime.now().toOffsetDateTime().toString()); | ||
response.put("utcTime", Instant.now().toString()); | ||
response.put("zoneId", ZoneId.systemDefault().toString()); | ||
|
||
if (serverInfo != null) { | ||
response.put("version", serverInfo.version); | ||
} | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@Component | ||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "server.info") | ||
static class ServerInfo { | ||
private String version; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/ch/uzh/ifi/access/config/GracefulShutdown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ch.uzh.ifi.access.config; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.event.ContextClosedEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class GracefulShutdown { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(GracefulShutdown.class); | ||
|
||
private boolean isShutdown = false; | ||
|
||
@EventListener(ContextClosedEvent.class) | ||
public void rejectSubmissionsOnShutdown() { | ||
logger.warn("Received shutdown signal. Will reject new submissions"); | ||
this.isShutdown = true; | ||
} | ||
|
||
public boolean isShutdown() { | ||
return isShutdown; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.