Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jans-link): add health check service in jans link #5608 #5685

Merged
merged 1 commit into from Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,34 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.link.service;

import java.util.HashSet;
import java.util.Set;

import io.jans.link.ws.rs.HealthCheckController;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;


/**
* Integration with Resteasy
*
* @author Yuriy Movchan
* @version 0.1, 11/13/2020
*/
@ApplicationPath("/sys")
public class SystemResteasyInitializer extends Application {

@Override
public Set<Class<?>> getClasses() {
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(HealthCheckController.class);

return classes;
}

}
@@ -0,0 +1,42 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.link.ws.rs;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import io.jans.orm.PersistenceEntryManager;

/**
* Health check controller
*
* @author Yuriy Movchan
* @version Jul 24, 2020
*/
@ApplicationScoped
@Path("/")
public class HealthCheckController {

@Inject
private PersistenceEntryManager persistenceEntryManager;

@GET
@POST
@Path("/health-check")
@Produces(MediaType.APPLICATION_JSON)
public String healthCheckController() {
boolean isConnected = persistenceEntryManager.getOperationService().isConnected();
String dbStatus = isConnected ? "online" : "offline";
return "{\"status\": \"running\", \"db_status\":\"" + dbStatus + "\"}";
}

}
2 changes: 1 addition & 1 deletion jans-link/server/src/main/webapp/index.jsp
@@ -1 +1 @@
<% out.print("Jans Config- Api"); %>
<% out.print("Jans Link "); %>