mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Add check for database session in healthcheck.
This commit is contained in:
parent
6376401d98
commit
d4c6383d55
1 changed files with 7 additions and 1 deletions
|
@ -44,7 +44,13 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||
AsyncServlet mainServlet(Executor executor) {
|
||||
|
||||
RoutingServlet router = RoutingServlet.create()
|
||||
.map(GET, "/healthcheck", request -> getRawResponse("OK".getBytes(UTF_8), "text/plain", "no-store"))
|
||||
.map(GET, "/healthcheck", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try (Session ignored = DatabaseSessionFactory.createSession()) {
|
||||
return getRawResponse("OK".getBytes(UTF_8), "text/plain", "no-store");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
}
|
||||
}))
|
||||
.map(GET, "/version", AsyncServlet.ofBlocking(executor, request -> getRawResponse(Constants.VERSION.getBytes(UTF_8), "text/plain", "no-store")))
|
||||
.map(HttpMethod.OPTIONS, "/*", request -> HttpResponse.ofCode(200))
|
||||
.map(GET, "/webhooks/pubsub", request -> HttpResponse.ok200().withPlainText(Objects.requireNonNull(request.getQueryParameter("hub.challenge"))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue