diff --git a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java index 0e716a0c..3d6827ed 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java +++ b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java @@ -18,7 +18,6 @@ package io.openvidu.server.config; import java.io.File; -import java.io.IOException; import java.net.Inet6Address; import java.net.MalformedURLException; import java.net.URI; @@ -51,7 +50,6 @@ import com.google.gson.JsonSyntaxException; import io.openvidu.java.client.OpenViduRole; import io.openvidu.server.OpenViduServer; import io.openvidu.server.cdr.CDREventName; -import io.openvidu.server.config.Dotenv.DotenvFormatException; import io.openvidu.server.recording.RecordingNotification; @Component @@ -105,8 +103,6 @@ public class OpenviduConfig { @Autowired protected Environment env; - protected Dotenv dotenv; - @Value("#{'${spring.profiles.active:}'.length() > 0 ? '${spring.profiles.active:}'.split(',') : \"default\"}") protected String springProfile; @@ -172,6 +168,8 @@ public class OpenviduConfig { protected int openviduSessionsGarbageThreshold; + private String dotenvPath; + // Derived properties public static String finalUrl; @@ -289,9 +287,13 @@ public class OpenviduConfig { public int getSessionGarbageThreshold() { return openviduSessionsGarbageThreshold; } + + public String getDotenvPath() { + return dotenvPath; + } // Derived properties methods - + public String getSpringProfile() { return springProfile; } @@ -371,11 +373,7 @@ public class OpenviduConfig { Object valueObj = propertiesSource.get(property); if (valueObj != null) { - if(valueObj instanceof Iterable) { - value = JsonUtils.toJson(valueObj); - } else { - value = valueObj.toString(); - } + value = valueObj.toString(); } } @@ -410,16 +408,6 @@ public class OpenviduConfig { @PostConstruct 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 { this.checkConfigurationProperties(); } catch (Exception e) { @@ -441,6 +429,8 @@ public class OpenviduConfig { protected void checkConfigurationProperties() { + + serverPort = getValue("server.port"); coturnRedisDbname = getValue("coturn.redis.dbname"); @@ -483,7 +473,8 @@ public class OpenviduConfig { checkWebhook(); checkCertificateType(); - + + dotenvPath = getValue("dotenv.path"); } private void checkCertificateType() { diff --git a/openvidu-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/openvidu-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 5aef5b1e..7a37b084 100644 --- a/openvidu-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/openvidu-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,218 +1,226 @@ -{ - "properties": [ - { - "name": "kms.uris", - "type": "java.lang.String", - "description": "KMS URL's to which OpenVidu Server will try to connect. They are tested in order until a valid one is found", - "defaultValue": "[\"ws://localhost:8888/kurento\"]" - }, - { - "name": "openvidu.secret", - "type": "java.lang.String", - "description": "Secret used to connect to OpenVidu Server. This value is required when using the REST API or any server client, as well as when connecting to openvidu-server dashboard", - "defaultValue": "MY_SECRET" - }, - { - "name": "openvidu.publicurl", - "type": "java.lang.String", - "description": "URL to connect clients to OpenVidu Server. This must be the full IP of your OpenVidu Server, including protocol, host and port (for example: https://my.openvidu.server.ip:4443). If no port argument is provided, 'server.port' param will be appended to it", - "defaultValue": "local" - }, - { - "name": "openvidu.cdr", - "type": "java.lang.Boolean", - "description": "Whether to enable Call Detail Record or not", - "defaultValue": false - }, - { - "name": "openvidu.cdr.path", - "type": "java.lang.String", - "description": "Where to store CDR files", - "defaultValue": "log" - }, - { - "name": "openvidu.recording", - "type": "java.lang.Boolean", - "description": "Whether to start OpenVidu Server with recording module service available or not (a Docker image will be downloaded during the first execution). Apart from setting this param to true, it is also necessary to explicitly configure sessions to be recorded", - "defaultValue": false - }, - { - "name": "openvidu.recording.path", - "type": "java.lang.String", - "description": "Where to store the recorded video files", - "defaultValue": "/opt/openvidu/recordings" - }, - { - "name": "openvidu.recording.public-access", - "type": "java.lang.Boolean", - "description": "'true' to allow public access to the video files specified in 'openviu.recording.path'. 'false' to only allow access to authenticated users", - "defaultValue": false - }, - { - "name": "openvidu.recording.notification", - "type": "java.lang.String", - "description": "Which users will receive a notfication (client events 'recordingStarted' and 'recordingStopped') when recording starts and stops: 'none', 'publisher_moderator', 'all'", - "defaultValue": "publisher_moderator" - }, - { - "name": "openvidu.recording.custom-layout", - "type": "java.lang.String", - "description": "Where should OpenVidu Server look for custom recording layouts", - "defaultValue": "/opt/openvidu/custom-layout" - }, - { - "name": "openvidu.recording.version", - "type": "java.lang.String", - "description": "Tag for openvidu/openvidu-recording Docker image" - }, - { - "name": "openvidu.recording.autostop-timeout", - "type": "java.lang.Integer", - "description": "Timeout in seconds for automatically stopping the recording of a session when last user disconnects or when it starts and no user is publishing (only if RecordingMode.MANUAL)", - "defaultValue": 120 - }, - { - "name": "openvidu.recording.composed-url", - "type": "java.lang.String", - "description": "URL the composed-video recording dockerized Chrome will use to connect to the recording layouts inside OpenVidu Server host. This will affect all video recording layouts (default one BEST_FIT, all CUSTOM layouts). This allows changing the default URL, which is 'openvidu.publicurl', for those cases where OpenVidu Server host does not allow back and forth connections using the public url from inside the host", - "defaultValue": "" - }, - { - "name": "openvidu.webhook", - "type": "java.lang.Boolean", - "description": "'true' to enable OpenVidu Server Webhook service. 'false' otherwise", - "defaultValue": false - }, - { - "name": "openvidu.webhook.endpoint", - "type": "java.lang.String", - "description": "HTTP endpoint where OpenVidu Server will send Webhook HTTP POST messages", - "defaultValue": "" - }, - { - "name": "openvidu.webhook.headers", - "type": "java.lang.String", - "description": "List of headers that OpenVidu Server Webhook service will attach to HTTP POST messages", - "defaultValue": "[]" - }, - { - "name": "openvidu.webhook.events", - "type": "java.lang.String", - "description": "List of events that will be sent by OpenVidu Server Webhook service", - "defaultValue": "[\"sessionCreated\",\"sessionDestroyed\",\"participantJoined\",\"participantLeft\",\"webrtcConnectionCreated\",\"webrtcConnectionDestroyed\",\"recordingStatusChanged\"]" - }, - { - "name": "openvidu.streams.video.max-recv-bandwidth", - "type": "java.lang.Integer", - "description": "Maximum video bandwidth sent from clients to OpenVidu Server, in kbps. 0 means unconstrained", - "defaultValue": 1000 - }, - { - "name": "openvidu.streams.video.min-recv-bandwidth", - "type": "java.lang.Integer", - "description": "Minimum video bandwidth sent from clients to OpenVidu Server, in kbps. 0 means unconstrained", - "defaultValue": 300 - }, - { - "name": "openvidu.streams.video.max-send-bandwidth", - "type": "java.lang.Integer", - "description": "Maximum video bandwidth sent from OpenVidu Server to clients, in kbps. 0 means unconstrained", - "defaultValue": 1000 - }, - { - "name": "openvidu.streams.video.min-send-bandwidth", - "type": "java.lang.Integer", - "description": "Minimum video bandwidth sent from OpenVidu Server to clients, in kbps. 0 means unconstrained", - "defaultValue": 300 - }, - { - "name": "openvidu.sessions.garbage.interval", - "type": "java.lang.Integer", - "description": "How often the garbage collector of non active sessions runs. This helps cleaning up sessions that have been initialized through REST API (and maybe tokens have been created for them) but have had no users connected. Default to 900s (15 mins). 0 to disable non active sessions garbage collector", - "defaultValue": 900 - }, - { - "name": "openvidu.sessions.garbage.threshold", - "type": "java.lang.Integer", - "description": "Minimum time in seconds that a non active session must have been in existence for the garbage collector of non active sessions to remove it. Default to 3600s (1 hour). If non active sessions garbage collector is disabled (property 'openvidu.sessions.garbage.interval' to 0) this property is ignored", - "defaultValue": 3600 - }, - { - "name": "coturn.ip", - "type": "java.lang.String", - "description": "Coturn IP of a deployed coturn server" - }, - { - "name": "coturn.redis.ip", - "type": "java.lang.String", - "description": "Redis IP where OpenVidu Server should connect to store TURN credentials", - "defaultValue": "127.0.0.1" - }, - { - "name": "coturn.redis.dbname", - "type": "java.lang.String", - "description": "Redis database where to store TURN credentials", - "defaultValue": "0" - }, - { - "name": "coturn.redis.password", - "type": "java.lang.String", - "description": "Password to connect OpenVidu Server to Redis database to store TURN credentials", - "defaultValue": "turn" - }, - { - "name": "coturn.redis.connect-timeout", - "type": "java.lang.Integer", - "description": "Timeout in seconds when OpenVidu Server is connecting to Redis database to store TURN credentials", - "defaultValue": 30 - }, - { - "name": "coturn.sqlite", - "type": "java.lang.String", - "description": "Path to COTURN sqlite database to add and remove TURN user credentials", - "defaultValue": "/opt/openvidu/coturn/turndb" - }, - { - "name": "jsonRpcClientWebSocket.reconnectionDelay", - "type": "java.lang.Integer", - "description": "Reconnection delay when Kurento Media Server connection is lost (ms)", - "defaultValue": 2000 - }, - { - "name": "jsonRpcClientWebSocket.timeout", - "type": "java.lang.Integer", - "description": "Timeout for RPC operations sent to KMS through websocket (ms)", - "defaultValue": 60000 - }, - { - "name": "jsonRpcClientWebSocket.packetSize", - "type": "java.lang.Integer", - "description": "Maximum size of packets sent through websocket", - "defaultValue": 1000000 - }, - { - "name": "jsonRpcClientWebSocket.connectionTimeout", - "type": "java.lang.Integer", - "description": "Timeout for openvidu-server to connect through websocket to KMS (ms)", - "defaultValue": 5000 - }, - { - "name": "kurento.client.keepAliveTime", - "type": "java.lang.Integer", - "description": "Heartbeat frecuency between openvidu-server and KMS (ms)", - "defaultValue": 240000 - }, - { - "name": "ws.sessionReconnectionTime", - "type": "java.lang.Integer", - "description": "Reconnection timeout between clients and openvidu-server (seconds)", - "defaultValue": 10 - }, - { - "name": "ws.maxSessions", - "type": "java.lang.Long", - "description": "Maximum number of websocket sessions that openvidu-server will be able to hold", - "defaultValue": 9223372036854775807 - } - ] -} \ No newline at end of file +{"properties": [ + { + "name": "kms.uris", + "type": "java.lang.String", + "description": "KMS URL's to which OpenVidu Server will try to connect. They are tested in order until a valid one is found", + "defaultValue": "[\"ws://localhost:8888/kurento\"]" + }, + { + "name": "openvidu.secret", + "type": "java.lang.String", + "description": "Secret used to connect to OpenVidu Server. This value is required when using the REST API or any server client, as well as when connecting to openvidu-server dashboard", + "defaultValue": "MY_SECRET" + }, + { + "name": "openvidu.publicurl", + "type": "java.lang.String", + "description": "URL to connect clients to OpenVidu Server. This must be the full IP of your OpenVidu Server, including protocol, host and port (for example: https://my.openvidu.server.ip:4443). If no port argument is provided, 'server.port' param will be appended to it", + "defaultValue": "local" + }, + { + "name": "openvidu.cdr", + "type": "java.lang.Boolean", + "description": "Whether to enable Call Detail Record or not", + "defaultValue": false + }, + { + "name": "openvidu.cdr.path", + "type": "java.lang.String", + "description": "Where to store CDR files", + "defaultValue": "log" + }, + { + "name": "openvidu.recording", + "type": "java.lang.Boolean", + "description": "Whether to start OpenVidu Server with recording module service available or not (a Docker image will be downloaded during the first execution). Apart from setting this param to true, it is also necessary to explicitly configure sessions to be recorded", + "defaultValue": false + }, + { + "name": "openvidu.recording.path", + "type": "java.lang.String", + "description": "Where to store the recorded video files", + "defaultValue": "/opt/openvidu/recordings" + }, + { + "name": "openvidu.recording.public-access", + "type": "java.lang.Boolean", + "description": "'true' to allow public access to the video files specified in 'openviu.recording.path'. 'false' to only allow access to authenticated users", + "defaultValue": false + }, + { + "name": "openvidu.recording.notification", + "type": "java.lang.String", + "description": "Which users will receive a notfication (client events 'recordingStarted' and 'recordingStopped') when recording starts and stops: 'none', 'publisher_moderator', 'all'", + "defaultValue": "publisher_moderator" + }, + { + "name": "openvidu.recording.custom-layout", + "type": "java.lang.String", + "description": "Where should OpenVidu Server look for custom recording layouts", + "defaultValue": "/opt/openvidu/custom-layout" + }, + { + "name": "openvidu.recording.version", + "type": "java.lang.String", + "description": "Tag for openvidu/openvidu-recording Docker image" + }, + { + "name": "openvidu.recording.autostop-timeout", + "type": "java.lang.Integer", + "description": "Timeout in seconds for automatically stopping the recording of a session when last user disconnects or when it starts and no user is publishing (only if RecordingMode.MANUAL)", + "defaultValue": 120 + }, + { + "name": "openvidu.recording.composed-url", + "type": "java.lang.String", + "description": "URL the composed-video recording dockerized Chrome will use to connect to the recording layouts inside OpenVidu Server host. This will affect all video recording layouts (default one BEST_FIT, all CUSTOM layouts). This allows changing the default URL, which is 'openvidu.publicurl', for those cases where OpenVidu Server host does not allow back and forth connections using the public url from inside the host", + "defaultValue": "" + }, + { + "name": "openvidu.webhook", + "type": "java.lang.Boolean", + "description": "'true' to enable OpenVidu Server Webhook service. 'false' otherwise", + "defaultValue": false + }, + { + "name": "openvidu.webhook.endpoint", + "type": "java.lang.String", + "description": "HTTP endpoint where OpenVidu Server will send Webhook HTTP POST messages", + "defaultValue": "" + }, + { + "name": "openvidu.webhook.headers", + "type": "java.lang.String", + "description": "List of headers that OpenVidu Server Webhook service will attach to HTTP POST messages", + "defaultValue": "[]" + }, + { + "name": "openvidu.webhook.events", + "type": "java.lang.String", + "description": "List of events that will be sent by OpenVidu Server Webhook service", + "defaultValue": "[\"sessionCreated\",\"sessionDestroyed\",\"participantJoined\",\"participantLeft\",\"webrtcConnectionCreated\",\"webrtcConnectionDestroyed\",\"recordingStatusChanged\"]" + }, + { + "name": "openvidu.streams.video.max-recv-bandwidth", + "type": "java.lang.Integer", + "description": "Maximum video bandwidth sent from clients to OpenVidu Server, in kbps. 0 means unconstrained", + "defaultValue": 1000 + }, + { + "name": "openvidu.streams.video.min-recv-bandwidth", + "type": "java.lang.Integer", + "description": "Minimum video bandwidth sent from clients to OpenVidu Server, in kbps. 0 means unconstrained", + "defaultValue": 300 + }, + { + "name": "openvidu.streams.video.max-send-bandwidth", + "type": "java.lang.Integer", + "description": "Maximum video bandwidth sent from OpenVidu Server to clients, in kbps. 0 means unconstrained", + "defaultValue": 1000 + }, + { + "name": "openvidu.streams.video.min-send-bandwidth", + "type": "java.lang.Integer", + "description": "Minimum video bandwidth sent from OpenVidu Server to clients, in kbps. 0 means unconstrained", + "defaultValue": 300 + }, + { + "name": "openvidu.sessions.garbage.interval", + "type": "java.lang.Integer", + "description": "How often the garbage collector of non active sessions runs. This helps cleaning up sessions that have been initialized through REST API (and maybe tokens have been created for them) but have had no users connected. Default to 900s (15 mins). 0 to disable non active sessions garbage collector", + "defaultValue": 900 + }, + { + "name": "openvidu.sessions.garbage.threshold", + "type": "java.lang.Integer", + "description": "Minimum time in seconds that a non active session must have been in existence for the garbage collector of non active sessions to remove it. Default to 3600s (1 hour). If non active sessions garbage collector is disabled (property 'openvidu.sessions.garbage.interval' to 0) this property is ignored", + "defaultValue": 3600 + }, + { + "name": "coturn.ip", + "type": "java.lang.String", + "description": "Coturn IP of a deployed coturn server" + }, + { + "name": "coturn.redis.ip", + "type": "java.lang.String", + "description": "Redis IP where OpenVidu Server should connect to store TURN credentials", + "defaultValue": "127.0.0.1" + }, + { + "name": "coturn.redis.dbname", + "type": "java.lang.String", + "description": "Redis database where to store TURN credentials", + "defaultValue": "0" + }, + { + "name": "coturn.redis.password", + "type": "java.lang.String", + "description": "Password to connect OpenVidu Server to Redis database to store TURN credentials", + "defaultValue": "turn" + }, + { + "name": "coturn.redis.connect-timeout", + "type": "java.lang.Integer", + "description": "Timeout in seconds when OpenVidu Server is connecting to Redis database to store TURN credentials", + "defaultValue": 30 + }, + { + "name": "coturn.sqlite", + "type": "java.lang.String", + "description": "Path to COTURN sqlite database to add and remove TURN user credentials", + "defaultValue": "/opt/openvidu/coturn/turndb" + }, + { + "name": "jsonRpcClientWebSocket.reconnectionDelay", + "type": "java.lang.Integer", + "description": "Reconnection delay when Kurento Media Server connection is lost (ms)", + "defaultValue": 2000 + }, + { + "name": "jsonRpcClientWebSocket.timeout", + "type": "java.lang.Integer", + "description": "Timeout for RPC operations sent to KMS through websocket (ms)", + "defaultValue": 60000 + }, + { + "name": "jsonRpcClientWebSocket.packetSize", + "type": "java.lang.Integer", + "description": "Maximum size of packets sent through websocket", + "defaultValue": 1000000 + }, + { + "name": "jsonRpcClientWebSocket.connectionTimeout", + "type": "java.lang.Integer", + "description": "Timeout for openvidu-server to connect through websocket to KMS (ms)", + "defaultValue": 5000 + }, + { + "name": "kurento.client.keepAliveTime", + "type": "java.lang.Integer", + "description": "Heartbeat frecuency between openvidu-server and KMS (ms)", + "defaultValue": 240000 + }, + { + "name": "ws.sessionReconnectionTime", + "type": "java.lang.Integer", + "description": "Reconnection timeout between clients and openvidu-server (seconds)", + "defaultValue": 10 + }, + { + "name": "ws.maxSessions", + "type": "java.lang.Long", + "description": "Maximum number of websocket sessions that openvidu-server will be able to hold", + "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'" + } +]} \ No newline at end of file diff --git a/openvidu-server/src/main/resources/application.properties b/openvidu-server/src/main/resources/application.properties index e9296029..6d8d559a 100644 --- a/openvidu-server/src/main/resources/application.properties +++ b/openvidu-server/src/main/resources/application.properties @@ -44,3 +44,5 @@ coturn.redis.ip=127.0.0.1 coturn.redis.dbname=0 coturn.redis.password=turn coturn.redis.connect-timeout=30 + +dotenv.path=.