Skip to content

Commit 2ec4352

Browse files
authored
Merge pull request #6 from lucee/fix/agent-warmup-skip
agent: skip init on warmup, mark step-handler daemon; add jdwp timeout=10000 to CI
2 parents 993d963 + 7963bea commit 2ec4352

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ jobs:
523523
echo "export LUCEE_DAP_SECRET=testing" >> debuggee/bin/setenv.sh
524524
echo "export LUCEE_LOGGING_FORCE_LEVEL=trace" >> debuggee/bin/setenv.sh
525525
echo "export LUCEE_DAP_DEBUG=true" >> debuggee/bin/setenv.sh
526-
echo "export CATALINA_OPTS=\"\$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999\"" >> debuggee/bin/setenv.sh
526+
echo "export CATALINA_OPTS=\"\$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999,timeout=10000\"" >> debuggee/bin/setenv.sh
527527
echo "export CATALINA_OPTS=\"\$CATALINA_OPTS -javaagent:\$CATALINA_HOME/$AGENT_JAR_NAME=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=\$CATALINA_HOME/$AGENT_JAR_NAME\"" >> debuggee/bin/setenv.sh
528528
chmod +x debuggee/bin/setenv.sh
529529

JAVA_AGENT.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Configures JDWP, the lower-level Java debugging protocol that the debugger agent
3535
| `server` | `y` | Use verbatim |
3636
| `suspend` | `n` | Use verbatim |
3737
| `address` | `localhost:9999` | Change only if port 9999 is in use |
38+
| `timeout` | `10000` | Recommended. Prevents JDWP from hanging at JVM shutdown if no debugger was ever connected (e.g. after a Lucee warmup run). |
3839

3940
**Note:** The VS Code debugger connects to the debugger agent, not JDWP directly, so these settings rarely need customising.
4041

@@ -99,14 +100,14 @@ For agent mode, you don't need the `secret` field - that's only for native exten
99100

100101
```bash
101102
#!/bin/bash
102-
CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999"
103+
CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999,timeout=10000"
103104
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/lucee/debugger/debugger-agent.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/opt/lucee/debugger/debugger-agent.jar"
104105
```
105106

106107
### Windows (setenv.bat)
107108

108109
```batch
109-
set CATALINA_OPTS=%CATALINA_OPTS% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999
110+
set CATALINA_OPTS=%CATALINA_OPTS% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999,timeout=10000
110111
set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:C:\lucee\debugger\debugger-agent.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=C:\lucee\debugger\debugger-agent.jar
111112
```
112113

@@ -125,3 +126,9 @@ You're running a JRE instead of a JDK. Install a full JDK.
125126
### Breakpoints not binding
126127

127128
Use the VS Code command palette and run "luceedebug: show class and breakpoint info" to see what's happening.
129+
130+
### Lucee warmup (`LUCEE_ENABLE_WARMUP`)
131+
132+
The agent automatically detects the `LUCEE_ENABLE_WARMUP` environment variable and skips initialization. No class instrumentation or DAP server setup happens during a warmup run. The real server start that follows will instrument classes normally as they are loaded.
133+
134+
This also avoids JDWP shutdown hangs during warmup — pair with `timeout=10000` in your JDWP args for reliable warmup exits.

source/java/src/org/lucee/extension/debugger/Agent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ public static void premain(String argString, Instrumentation inst) throws Throwa
265265
// TODO: clarify the exact failure case we are attempting to workaround here.
266266
System.out.println("[luceedebug] version " + Version.VERSION);
267267

268+
if (System.getenv("LUCEE_ENABLE_WARMUP") != null) {
269+
System.out.println("[luceedebug] warmup mode detected, skipping initialization");
270+
return;
271+
}
272+
268273
try (var jarFile = new JarFile(parsedArgs.jarPath)) {
269274
inst.appendToSystemClassLoaderSearch(jarFile);
270275
var classInjections = jarFile

source/java/src/org/lucee/extension/debugger/coreinject/LuceeVm.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ static BpLineAndId[] getLineInfo(Collection<ReplayableCfBreakpointRequest> vs) {
177177
}
178178

179179
private final ThreadMap threadMap_ = new ThreadMap();
180-
private final ExecutorService stepHandlerExecutor = Executors.newSingleThreadExecutor();
180+
private final ExecutorService stepHandlerExecutor = Executors.newSingleThreadExecutor(r -> {
181+
var t = new Thread(r, "luceedebug-step-handler");
182+
t.setDaemon(true);
183+
return t;
184+
});
181185
private final ConcurrentHashMap<CanonicalServerAbsPath, Set<ReplayableCfBreakpointRequest>> replayableBreakpointRequestsByAbsPath_ = new ConcurrentHashMap<>();
182186

183187
/**

0 commit comments

Comments
 (0)