added logging to initializer service
This commit is contained in:
parent
f72f1b76fe
commit
bee90dcef0
@ -15,6 +15,8 @@ import java.util.stream.Collectors;
|
|||||||
import org.ros.chatto.model.ApplicationStatus;
|
import org.ros.chatto.model.ApplicationStatus;
|
||||||
import org.ros.chatto.model.UserSession;
|
import org.ros.chatto.model.UserSession;
|
||||||
import org.ros.chatto.repository.UserSessionRepository;
|
import org.ros.chatto.repository.UserSessionRepository;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
@ -53,6 +55,8 @@ public class DBInitializerService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserSessionRepository userSessionRepository;
|
private UserSessionRepository userSessionRepository;
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(DBInitializerService.class);
|
||||||
|
|
||||||
|
|
||||||
public void connectDB() throws SQLException {
|
public void connectDB() throws SQLException {
|
||||||
connection = DriverManager.getConnection(url, userName, password);
|
connection = DriverManager.getConnection(url, userName, password);
|
||||||
@ -79,13 +83,14 @@ public class DBInitializerService {
|
|||||||
|
|
||||||
connectDB();
|
connectDB();
|
||||||
|
|
||||||
System.out.println("Hello world, I have just started up");
|
logger.info("Application Started - running initializer service");
|
||||||
|
|
||||||
// System.out.println("Checking database and application state");
|
// System.out.println("Checking database and application state");
|
||||||
//
|
//
|
||||||
|
|
||||||
if (getNumTables() == 0)
|
if (getNumTables() == 0) {
|
||||||
|
logger.info("Database is empty. Populating tables and roles");
|
||||||
populateDB();
|
populateDB();
|
||||||
|
}
|
||||||
closeConnection();
|
closeConnection();
|
||||||
|
|
||||||
resetAllUserSessions(userSessionRepository.findAll());
|
resetAllUserSessions(userSessionRepository.findAll());
|
||||||
|
Loading…
Reference in New Issue
Block a user