Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ public static String getConfig(String key) {
AssertUtil.notNull(key, "key cannot be null");
return props.get(key);
}

/**
* Get config value of the specific key.
*
* @param key config key
* @param envVariableKey Get the value of the environment variable with the given key
* @return the config value.
*/
public static String getConfig(String key, boolean envVariableKey) {
AssertUtil.notNull(key, "key cannot be null");
if (envVariableKey) {
String value = System.getenv(key);
if (StringUtil.isNotEmpty(value)) {
return value;
}
}
return getConfig(key);
}

public static void setConfig(String key, String value) {
AssertUtil.notNull(key, "key cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static String getPort() {
if (runtimePort > 0) {
return String.valueOf(runtimePort);
}
return SentinelConfig.getConfig(SERVER_PORT);
return SentinelConfig.getConfig(SERVER_PORT, true);
}

/**
Expand All @@ -159,7 +159,7 @@ public static void setRuntimePort(int port) {
* @return the local ip.
*/
public static String getHeartbeatClientIp() {
String ip = SentinelConfig.getConfig(HEARTBEAT_CLIENT_IP);
String ip = SentinelConfig.getConfig(HEARTBEAT_CLIENT_IP, true);
if (StringUtil.isBlank(ip)) {
ip = HostNameUtil.getIp();
}
Expand Down