- Increase the lower and upper limits for the Java Heap Size.
- Update the "ServerBaseURL" to the Public IP Address of the machine which is running the app.
This commit is contained in:
parent
dea257b87f
commit
a46ab84f10
|
@ -55,6 +55,12 @@ dependencies {
|
|||
testImplementation "org.springframework.boot:spring-boot-starter-test"
|
||||
}
|
||||
|
||||
// Set increased lower and upper limits for the java-execution.
|
||||
tasks.withType(JavaExec) {
|
||||
jvmArgs = ['-Xms512m', '-Xmx8g']
|
||||
}
|
||||
|
||||
|
||||
configurations {
|
||||
// Eliminates slf4j-log4j12
|
||||
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
|
||||
|
|
|
@ -5,7 +5,11 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class UriBuilder {
|
||||
|
||||
|
@ -24,7 +28,10 @@ public class UriBuilder {
|
|||
baseUrl += sslEnabled.equals("true") ? "s" : "";
|
||||
baseUrl += "://";
|
||||
|
||||
String hostName = InetAddress.getLoopbackAddress().getHostName(); // Non-null.
|
||||
String hostName = getPublicIP();
|
||||
if ( hostName == null )
|
||||
hostName = InetAddress.getLoopbackAddress().getHostName(); // Non-null.
|
||||
|
||||
baseUrl += hostName;
|
||||
String serverPort = environment.getProperty("server.port");
|
||||
if (serverPort == null) { // This is unacceptable!
|
||||
|
@ -34,11 +41,11 @@ public class UriBuilder {
|
|||
baseUrl += ":" + serverPort;
|
||||
|
||||
String baseInternalPath = environment.getProperty("server.servlet.context-path");
|
||||
if (baseInternalPath != null) {
|
||||
if (!baseInternalPath.startsWith("/"))
|
||||
if ( baseInternalPath != null ) {
|
||||
if ( !baseInternalPath.startsWith("/") )
|
||||
baseUrl += "/";
|
||||
baseUrl += baseInternalPath;
|
||||
if (!baseInternalPath.endsWith("/"))
|
||||
if ( !baseInternalPath.endsWith("/") )
|
||||
baseUrl += "/";
|
||||
} else {
|
||||
logger.warn("No property \"server.servlet.context-path\" was found in \"application.properties\"!"); // Yes it's expected.
|
||||
|
@ -48,6 +55,25 @@ public class UriBuilder {
|
|||
logger.debug("ServerBaseURL: " + baseUrl);
|
||||
}
|
||||
|
||||
private static String getPublicIP()
|
||||
{
|
||||
String publicIpAddress = "";
|
||||
URL url_name;
|
||||
try {
|
||||
url_name = new URL("https://api.ipify.org/");
|
||||
} catch (MalformedURLException mue) {
|
||||
logger.warn(mue.getMessage());
|
||||
return null;
|
||||
}
|
||||
try (BufferedReader bf = new BufferedReader(new InputStreamReader(url_name.openStream()))) {
|
||||
publicIpAddress = bf.readLine().trim();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Cannot get the publicIP address for this machine!", e);
|
||||
return null;
|
||||
}
|
||||
return publicIpAddress;
|
||||
}
|
||||
|
||||
public static String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue