KEYCLOAK-1935 Stop KeycloakServer if Undertow fails to start
This commit is contained in:
parent
fc0a3c3e73
commit
1342904fae
1 changed files with 29 additions and 22 deletions
|
@ -46,6 +46,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.BindException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +290,9 @@ public class KeycloakServer {
|
||||||
.setWorkerThreads(config.getWorkerThreads())
|
.setWorkerThreads(config.getWorkerThreads())
|
||||||
.setIoThreads(config.getWorkerThreads() / 8);
|
.setIoThreads(config.getWorkerThreads() / 8);
|
||||||
|
|
||||||
server = new UndertowJaxrsServer().start(builder);
|
server = new UndertowJaxrsServer();
|
||||||
|
try {
|
||||||
|
server.start(builder);
|
||||||
|
|
||||||
DeploymentInfo di = server.undertowDeployment(deployment, "");
|
DeploymentInfo di = server.undertowDeployment(deployment, "");
|
||||||
di.setClassLoader(getClass().getClassLoader());
|
di.setClassLoader(getClass().getClassLoader());
|
||||||
|
@ -320,6 +323,10 @@ public class KeycloakServer {
|
||||||
|
|
||||||
info("Started Keycloak (http://" + config.getHost() + ":" + config.getPort() + "/auth) in "
|
info("Started Keycloak (http://" + config.getHost() + ":" + config.getPort() + "/auth) in "
|
||||||
+ (System.currentTimeMillis() - start) + " ms\n");
|
+ (System.currentTimeMillis() - start) + " ms\n");
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
server.stop();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void info(String message) {
|
private void info(String message) {
|
||||||
|
|
Loading…
Reference in a new issue