From 17f946ef3fcd66f9930259afdad175cecf312299 Mon Sep 17 00:00:00 2001 From: Olivier Levitt Date: Tue, 17 Dec 2024 16:16:31 +0100 Subject: [PATCH] Allow JMX debug (#536) --- README.md | 2 ++ onyxia-api/entrypoint.sh | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3909ae29..abe06939 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ Configurable properties : | `logging.structured.format.console` | `` | Format for structured logging. Valid values : `ecs`, `gelf`, `logstash`. Leave empty for no structured logging (default). See https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.structured | | `springdoc.swagger-ui.path` | `/` | Open API (swagger) UI path | | `springdoc.swagger-ui.oauth.clientId` | `` | clientid used by swagger to authenticate the user, in general the same which is used by onyxia-ui is ok. | +| `DEBUG_JMX` | `` | Enable JMX monitoring. This is useful for profiling the app to improve performance but is not intended for production / daily use. Once enabled (`true`), use `kubectl port-forward` + a profiler (e.g VisualVM) to profile the app. | +| `JMX_PORT` | `10000` | Port used by JMX if enabled. | ## Onyxia API dependency to Helm diff --git a/onyxia-api/entrypoint.sh b/onyxia-api/entrypoint.sh index c4437bfe..56512b24 100755 --- a/onyxia-api/entrypoint.sh +++ b/onyxia-api/entrypoint.sh @@ -13,4 +13,9 @@ if [[ -n "$CACERTS_DIR" ]]; then fi # Run application -java org.springframework.boot.loader.launch.JarLauncher +if [ -n "$DEBUG_JMX" ]; then + JMX_PORT="${JMX_PORT:-10000}" + java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=127.0.0.1 org.springframework.boot.loader.launch.JarLauncher +else + java org.springframework.boot.loader.launch.JarLauncher +fi \ No newline at end of file