X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.lib.jetty%2Fsrc%2Forg%2Fargeo%2Fcms%2Fjetty%2FJettyHttpServer.java;h=80cff8b012bba5e5f55b56dd9a9fcd2e5924eac3;hb=00fec502abb8eeccb813fe33d5e9ba53436b44d6;hp=e414f5f984f3053dfc54ac3278069d0314cf83a0;hpb=d999febebc146ddbe236b46b5c8481f91a626c26;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java b/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java index e414f5f98..80cff8b01 100644 --- a/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java +++ b/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java @@ -112,6 +112,17 @@ public class JettyHttpServer extends HttpsServer { server.start(); // + // Addresses + String httpHost = getDeployProperty(CmsDeployProperty.HOST); + String fallBackHostname = cmsState != null ? cmsState.getHostname() : "::1"; + if (httpConnector != null) + httpAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, + httpConnector.getLocalPort()); + if (httpsConnector != null) + httpsAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, + httpsConnector.getLocalPort()); + + // Clean up Runtime.getRuntime().addShutdownHook(new Thread(() -> stop(), "Jetty shutdown")); log.info(httpPortsMsg()); @@ -214,7 +225,6 @@ public class JettyHttpServer extends HttpsServer { if (httpPortStr != null || httpsPortStr != null) { // TODO deal with hostname resolving taking too much time // String fallBackHostname = InetAddress.getLocalHost().getHostName(); - String fallBackHostname = cmsState != null ? cmsState.getHostname() : "::1"; boolean httpEnabled = httpPortStr != null; // props.put(JettyHttpConstants.HTTP_ENABLED, httpEnabled); @@ -233,7 +243,6 @@ public class JettyHttpServer extends HttpsServer { httpConnector.setHost(httpHost); httpConnector.setIdleTimeout(DEFAULT_IDLE_TIMEOUT); - httpAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpPort); } if (httpsEnabled) { @@ -269,8 +278,6 @@ public class JettyHttpServer extends HttpsServer { int httpsPort = Integer.parseInt(httpsPortStr); httpsConnector.setPort(httpsPort); httpsConnector.setHost(httpHost); - - httpsAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpsPort); } }