mirror of https://github.com/OpenVidu/openvidu.git
Add dotenv path to allow updating file when restart
parent
0a36927836
commit
8c1703aa54
|
@ -18,7 +18,6 @@
|
||||||
package io.openvidu.server.config;
|
package io.openvidu.server.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -51,7 +50,6 @@ import com.google.gson.JsonSyntaxException;
|
||||||
import io.openvidu.java.client.OpenViduRole;
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
import io.openvidu.server.OpenViduServer;
|
import io.openvidu.server.OpenViduServer;
|
||||||
import io.openvidu.server.cdr.CDREventName;
|
import io.openvidu.server.cdr.CDREventName;
|
||||||
import io.openvidu.server.config.Dotenv.DotenvFormatException;
|
|
||||||
import io.openvidu.server.recording.RecordingNotification;
|
import io.openvidu.server.recording.RecordingNotification;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -105,8 +103,6 @@ public class OpenviduConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
protected Environment env;
|
protected Environment env;
|
||||||
|
|
||||||
protected Dotenv dotenv;
|
|
||||||
|
|
||||||
@Value("#{'${spring.profiles.active:}'.length() > 0 ? '${spring.profiles.active:}'.split(',') : \"default\"}")
|
@Value("#{'${spring.profiles.active:}'.length() > 0 ? '${spring.profiles.active:}'.split(',') : \"default\"}")
|
||||||
protected String springProfile;
|
protected String springProfile;
|
||||||
|
|
||||||
|
@ -172,6 +168,8 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
protected int openviduSessionsGarbageThreshold;
|
protected int openviduSessionsGarbageThreshold;
|
||||||
|
|
||||||
|
private String dotenvPath;
|
||||||
|
|
||||||
// Derived properties
|
// Derived properties
|
||||||
|
|
||||||
public static String finalUrl;
|
public static String finalUrl;
|
||||||
|
@ -290,6 +288,10 @@ public class OpenviduConfig {
|
||||||
return openviduSessionsGarbageThreshold;
|
return openviduSessionsGarbageThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDotenvPath() {
|
||||||
|
return dotenvPath;
|
||||||
|
}
|
||||||
|
|
||||||
// Derived properties methods
|
// Derived properties methods
|
||||||
|
|
||||||
public String getSpringProfile() {
|
public String getSpringProfile() {
|
||||||
|
@ -371,13 +373,9 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
Object valueObj = propertiesSource.get(property);
|
Object valueObj = propertiesSource.get(property);
|
||||||
if (valueObj != null) {
|
if (valueObj != null) {
|
||||||
if(valueObj instanceof Iterable) {
|
|
||||||
value = JsonUtils.toJson(valueObj);
|
|
||||||
} else {
|
|
||||||
value = valueObj.toString();
|
value = valueObj.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
value = env.getProperty(property);
|
value = env.getProperty(property);
|
||||||
|
@ -410,16 +408,6 @@ public class OpenviduConfig {
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void checkConfiguration() {
|
public void checkConfiguration() {
|
||||||
|
|
||||||
dotenv = new Dotenv();
|
|
||||||
|
|
||||||
try {
|
|
||||||
dotenv.read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Exception reading .env file. " + e.getClass() + ":" + e.getMessage());
|
|
||||||
} catch (DotenvFormatException e) {
|
|
||||||
log.warn("Format error in .env file. " + e.getClass() + ":" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.checkConfigurationProperties();
|
this.checkConfigurationProperties();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -441,6 +429,8 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
protected void checkConfigurationProperties() {
|
protected void checkConfigurationProperties() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
serverPort = getValue("server.port");
|
serverPort = getValue("server.port");
|
||||||
|
|
||||||
coturnRedisDbname = getValue("coturn.redis.dbname");
|
coturnRedisDbname = getValue("coturn.redis.dbname");
|
||||||
|
@ -484,6 +474,7 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
checkCertificateType();
|
checkCertificateType();
|
||||||
|
|
||||||
|
dotenvPath = getValue("dotenv.path");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCertificateType() {
|
private void checkCertificateType() {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{"properties": [
|
||||||
"properties": [
|
|
||||||
{
|
{
|
||||||
"name": "kms.uris",
|
"name": "kms.uris",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
|
@ -213,6 +212,15 @@
|
||||||
"type": "java.lang.Long",
|
"type": "java.lang.Long",
|
||||||
"description": "Maximum number of websocket sessions that openvidu-server will be able to hold",
|
"description": "Maximum number of websocket sessions that openvidu-server will be able to hold",
|
||||||
"defaultValue": 9223372036854775807
|
"defaultValue": 9223372036854775807
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "certificate.type",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "A description for 'certificate.type'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dotenvpath",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "A description for 'dotenvpath'"
|
||||||
}
|
}
|
||||||
]
|
]}
|
||||||
}
|
|
|
@ -44,3 +44,5 @@ coturn.redis.ip=127.0.0.1
|
||||||
coturn.redis.dbname=0
|
coturn.redis.dbname=0
|
||||||
coturn.redis.password=turn
|
coturn.redis.password=turn
|
||||||
coturn.redis.connect-timeout=30
|
coturn.redis.connect-timeout=30
|
||||||
|
|
||||||
|
dotenv.path=.
|
||||||
|
|
Loading…
Reference in New Issue