diff options
Diffstat (limited to 'subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java')
-rw-r--r-- | subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java b/subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java index ad19e77d..155efc6f 100644 --- a/subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java +++ b/subprojects/language-web/src/main/java/tools/refinery/language/web/ServerLauncher.java | |||
@@ -33,7 +33,7 @@ import java.util.EnumSet; | |||
33 | import java.util.Set; | 33 | import java.util.Set; |
34 | 34 | ||
35 | public class ServerLauncher { | 35 | public class ServerLauncher { |
36 | public static final String DEFAULT_LISTEN_ADDRESS = "localhost"; | 36 | public static final String DEFAULT_LISTEN_HOST = "localhost"; |
37 | 37 | ||
38 | public static final int DEFAULT_LISTEN_PORT = 1312; | 38 | public static final int DEFAULT_LISTEN_PORT = 1312; |
39 | 39 | ||
@@ -105,7 +105,7 @@ public class ServerLauncher { | |||
105 | 105 | ||
106 | private Resource getBaseResource() { | 106 | private Resource getBaseResource() { |
107 | var factory = ResourceFactory.of(server); | 107 | var factory = ResourceFactory.of(server); |
108 | var baseResourceOverride = System.getenv("BASE_RESOURCE"); | 108 | var baseResourceOverride = System.getenv("REFINERY_BASE_RESOURCE"); |
109 | if (baseResourceOverride != null) { | 109 | if (baseResourceOverride != null) { |
110 | // If a user override is provided, use it. | 110 | // If a user override is provided, use it. |
111 | return factory.newResource(baseResourceOverride); | 111 | return factory.newResource(baseResourceOverride); |
@@ -115,7 +115,10 @@ public class ServerLauncher { | |||
115 | // If the app is packaged in the jar, serve it. | 115 | // If the app is packaged in the jar, serve it. |
116 | URI webRootUri; | 116 | URI webRootUri; |
117 | try { | 117 | try { |
118 | webRootUri = URI.create(indexUrlInJar.toURI().toASCIIString().replaceFirst("/index.html$", "/")); | 118 | webRootUri = URI.create(indexUrlInJar.toURI().toASCIIString() |
119 | .replaceFirst("/index.html$", "/") | ||
120 | // Enable running without warnings from a jar. | ||
121 | .replaceFirst("^jar:file:", "jar:file://")); | ||
119 | } catch (URISyntaxException e) { | 122 | } catch (URISyntaxException e) { |
120 | throw new IllegalStateException("Jar has invalid base resource URI", e); | 123 | throw new IllegalStateException("Jar has invalid base resource URI", e); |
121 | } | 124 | } |
@@ -152,17 +155,17 @@ public class ServerLauncher { | |||
152 | } | 155 | } |
153 | 156 | ||
154 | private static String getListenAddress() { | 157 | private static String getListenAddress() { |
155 | var listenAddress = System.getenv("LISTEN_ADDRESS"); | 158 | var listenAddress = System.getenv("REFINERY_LISTEN_HOST"); |
156 | if (listenAddress == null) { | 159 | if (listenAddress == null) { |
157 | return DEFAULT_LISTEN_ADDRESS; | 160 | return DEFAULT_LISTEN_HOST; |
158 | } | 161 | } |
159 | return listenAddress; | 162 | return listenAddress; |
160 | } | 163 | } |
161 | 164 | ||
162 | private static int getListenPort() { | 165 | private static int getListenPort() { |
163 | var portStr = System.getenv("LISTEN_PORT"); | 166 | var portStr = System.getenv("REFINERY_LISTEN_PORT"); |
164 | if (portStr != null) { | 167 | if (portStr != null) { |
165 | return Integer.parseInt(portStr); | 168 | return Integer.parseUnsignedInt(portStr); |
166 | } | 169 | } |
167 | return DEFAULT_LISTEN_PORT; | 170 | return DEFAULT_LISTEN_PORT; |
168 | } | 171 | } |
@@ -174,7 +177,7 @@ public class ServerLauncher { | |||
174 | } | 177 | } |
175 | 178 | ||
176 | private static String getPublicHost() { | 179 | private static String getPublicHost() { |
177 | var publicHost = System.getenv("PUBLIC_HOST"); | 180 | var publicHost = System.getenv("REFINERY_PUBLIC_HOST"); |
178 | if (publicHost != null) { | 181 | if (publicHost != null) { |
179 | return publicHost.toLowerCase(); | 182 | return publicHost.toLowerCase(); |
180 | } | 183 | } |
@@ -182,15 +185,15 @@ public class ServerLauncher { | |||
182 | } | 185 | } |
183 | 186 | ||
184 | private static int getPublicPort() { | 187 | private static int getPublicPort() { |
185 | var portStr = System.getenv("PUBLIC_PORT"); | 188 | var portStr = System.getenv("REFINERY_PUBLIC_PORT"); |
186 | if (portStr != null) { | 189 | if (portStr != null) { |
187 | return Integer.parseInt(portStr); | 190 | return Integer.parseUnsignedInt(portStr); |
188 | } | 191 | } |
189 | return DEFAULT_PUBLIC_PORT; | 192 | return DEFAULT_PUBLIC_PORT; |
190 | } | 193 | } |
191 | 194 | ||
192 | private static String[] getAllowedOrigins() { | 195 | private static String[] getAllowedOrigins() { |
193 | var allowedOrigins = System.getenv("ALLOWED_ORIGINS"); | 196 | var allowedOrigins = System.getenv("REFINERY_ALLOWED_ORIGINS"); |
194 | if (allowedOrigins != null) { | 197 | if (allowedOrigins != null) { |
195 | return allowedOrigins.split(ALLOWED_ORIGINS_SEPARATOR); | 198 | return allowedOrigins.split(ALLOWED_ORIGINS_SEPARATOR); |
196 | } | 199 | } |
@@ -219,12 +222,10 @@ public class ServerLauncher { | |||
219 | int port; | 222 | int port; |
220 | var publicHost = getPublicHost(); | 223 | var publicHost = getPublicHost(); |
221 | if (publicHost == null) { | 224 | if (publicHost == null) { |
222 | host = getListenAddress(); | 225 | return null; |
223 | port = getListenPort(); | ||
224 | } else { | ||
225 | host = publicHost; | ||
226 | port = getPublicPort(); | ||
227 | } | 226 | } |
227 | host = publicHost; | ||
228 | port = getPublicPort(); | ||
228 | var scheme = port == HTTPS_DEFAULT_PORT ? "wss" : "ws"; | 229 | var scheme = port == HTTPS_DEFAULT_PORT ? "wss" : "ws"; |
229 | return String.format("%s://%s:%d/xtext-service", scheme, host, port); | 230 | return String.format("%s://%s:%d/xtext-service", scheme, host, port); |
230 | } | 231 | } |