Explorar el Código

check table even if db connection is ok

tags/2.0.1
Jonathan Cobb hace 4 años
padre
commit
b53f5d1c49
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. +7
    -4
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/SystemInitializerListener.java

+ 7
- 4
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/SystemInitializerListener.java Ver fichero

@@ -39,11 +39,12 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {


try { try {
config.execSql("select 1"); config.execSql("select 1");
checkTable(config);
log.info("database configured OK, skipping initialization"); log.info("database configured OK, skipping initialization");
return; return;


} catch (Exception e) { } catch (Exception e) {
log.warn(PREFIX+"database not configured, attempting to initialize...");
log.warn(PREFIX+"database not properly configured, attempting to initialize...");
} }


try { try {
@@ -84,7 +85,11 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {
die(PREFIX+"database configuration failed, cannot run test query: "+shortError(e)); die(PREFIX+"database configuration failed, cannot run test query: "+shortError(e));
} }


// does a proper table exist?
checkTable(config);
super.beforeStart(server);
}

public void checkTable(PgRestServerConfiguration config) {
if (!empty(checkTable)) { if (!empty(checkTable)) {
if (!checkSafeShellArg(checkTable)) invalidName("invalid table name", checkTable); if (!checkSafeShellArg(checkTable)) invalidName("invalid table name", checkTable);
try { try {
@@ -94,8 +99,6 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {
config.getDatabase().getHibernate().setHbm2ddlAuto("create"); config.getDatabase().getHibernate().setHbm2ddlAuto("create");
} }
} }

super.beforeStart(server);
} }


@Override public void onStart(RestServer server) { @Override public void onStart(RestServer server) {


Cargando…
Cancelar
Guardar