Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config for debug logging and remote debugging #790

Merged
merged 14 commits into from
Mar 26, 2024
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions docs/deployment-guide/goals/production/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
5 changes: 4 additions & 1 deletion launchers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
43 changes: 43 additions & 0 deletions launchers/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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[@]}"
7 changes: 7 additions & 0 deletions launchers/logging.dev.properties
Original file line number Diff line number Diff line change
@@ -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
Loading