diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc813e7f..658a594c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). - UIAsset: Replaced unsafe additional and private properties with safer alternative fields `customJsonAsString` (**not** affected by Json LD manipulation) and `customJsonLdAsString` (affected by Json LD manipulation), along with their private counterparts. - API Wrapper: TS Client Library now supports OAuth Client Credentials +- EDC Backend: Added config variables for remote debugging #### Patch Changes @@ -27,6 +28,12 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). - EDC UI: - New **optional** environment variable: `EDC_UI_MANAGEMENT_API_URL_SHOWN_IN_DASHBOARD` as override for shown Management API URL on the dashboard +- EDC Backend: + - New **optional** environment variables to enable and configure remote logging & debugging capabilities: + - `DEBUG_LOGGING = false` + - `REMOTE_DEBUG = false` + - `REMOTE_DEBUG_SUSPEND = false` + - `REMOTE_DEBUG_BIND = 127.0.0.1:5005` #### Compatible Versions diff --git a/docker-compose.yaml b/docker-compose.yaml index 695e35276..ac61499e8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,6 +4,7 @@ services: image: ${EDC_UI_IMAGE} ports: - '11000:8080' + - '33005:5005' environment: EDC_UI_ACTIVE_PROFILE: ${EDC_UI_ACTIVE_PROFILE} EDC_UI_CONFIG_URL: edc-ui-config diff --git a/docs/deployment-guide/goals/production/README.md b/docs/deployment-guide/goals/production/README.md index e87cc0fb1..9139c4887 100644 --- a/docs/deployment-guide/goals/production/README.md +++ b/docs/deployment-guide/goals/production/README.md @@ -150,6 +150,17 @@ EDC_OAUTH_CERTIFICATE_ALIAS: 1 EDC_OAUTH_PRIVATE_KEY_ALIAS: 1 ``` +You can also optionally set the following config properties: +```yaml +# Enables DEBUG-Level logging +DEBUG_LOGGING: true + +# Enables JDWP Remote Debugging +REMOTE_DEBUG: true +REMOTE_DEBUG_SUSPEND: true # default: false +REMOTE_DEBUG_BIND: 127.0.0.1:5005 # default: 127.0.0.1:5005 +``` + ## FAQ ### What should the client ID entry look like? diff --git a/launchers/Dockerfile b/launchers/Dockerfile index cd5595898..a4dbda971 100644 --- a/launchers/Dockerfile +++ b/launchers/Dockerfile @@ -18,6 +18,7 @@ ARG EDC_BUILD_DATE_ARG="The docker container was built outside of github actions WORKDIR /app COPY ./launchers/connectors/$CONNECTOR_NAME/build/libs/app.jar /app COPY ./launchers/logging.properties /app +COPY ./launchers/logging.dev.properties /app COPY ./launchers/.env /app/.env RUN touch /app/emtpy-properties-file.properties @@ -28,7 +29,9 @@ ENV EDC_LAST_COMMIT_INFO=$EDC_LAST_COMMIT_INFO_ARG ENV EDC_BUILD_DATE=$EDC_BUILD_DATE_ARG ENV JVM_ARGS="" -ENTRYPOINT set -a && source /app/.env && set +a && exec java -Djava.util.logging.config.file=/app/logging.properties $JVM_ARGS -jar app.jar +COPY ./launchers/docker-entrypoint.sh /app/entrypoint.sh +ENTRYPOINT ["/app/entrypoint.sh"] +CMD ["start"] # health status is determined by the availability of the /health endpoint HEALTHCHECK --interval=5s --timeout=5s --retries=10 CMD curl --fail http://localhost:11001/api/check/health diff --git a/launchers/docker-entrypoint.sh b/launchers/docker-entrypoint.sh new file mode 100755 index 000000000..1f463be66 --- /dev/null +++ b/launchers/docker-entrypoint.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Use bash instead of sh, +# because sh in this image is provided by dash (https://git.kernel.org/pub/scm/utils/dash/dash.git/), +# which seems to eat environment variables containing dashes, +# which are required for some EDC configuration values. + +# Do not set -u to permit unset variables in .env +set -eo pipefail + +# Apply ENV Vars on JAR startup +set -a +source /app/.env +set +a + + +if [[ "x${1:-}" == "xstart" ]]; then + cmd=(java ${JAVA_ARGS:-}) + + if [ "${REMOTE_DEBUG:-n}" = "y" ] || [ "${REMOTE_DEBUG:-false}" = "true" ]; then + cmd+=( + "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${REMOTE_DEBUG_SUSPEND:-n},address=${REMOTE_DEBUG_BIND:-127.0.0.1:5005}" + ) + fi + + logging_config='/app/logging.properties' + if [ "${DEBUG_LOGGING:-n}" = "y" ] || [ "${DEBUG_LOGGING:-false}" = "true" ]; then + logging_config='/app/logging.dev.properties' + fi + + cmd+=( + -Djava.util.logging.config.file=${logging_config} + -jar /app/app.jar + ) +else + cmd=("$@") +fi + +if [ "${REMOTE_DEBUG:-n}" = "y" ] || [ "${REMOTE_DEBUG:-false}" = "true" ]; then + echo "Jar CMD (printing, because REMOTE_DEBUG=y|true): ${cmd[@]}" +fi + +# Use "exec" for termination signals to reach JVM +exec "${cmd[@]}" diff --git a/launchers/logging.dev.properties b/launchers/logging.dev.properties new file mode 100644 index 000000000..3db949d79 --- /dev/null +++ b/launchers/logging.dev.properties @@ -0,0 +1,7 @@ +handlers = java.util.logging.ConsoleHandler +.level = FINE +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.SimpleFormatter.format = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %5$s %6$s%n +org.eclipse.dataspaceconnector.level = FINE +org.eclipse.dataspaceconnector.handler = java.util.logging.ConsoleHandler