@@ -10,6 +10,8 @@ export const OVERRIDES_DIR = path.join(APP_ROOT, 'overrides');
10
10
const OVERRIDE_RUBYGEMS_PATH = path . join ( OVERRIDES_DIR , 'gems' ) ;
11
11
const OVERRIDE_PYTHONPATH = path . join ( OVERRIDES_DIR , 'pythonpath' ) ;
12
12
13
+ export const OVERRIDE_JAVA_AGENT = path . join ( OVERRIDES_DIR , 'java-agent.jar' ) ;
14
+
13
15
const OVERRIDE_JS_SCRIPT = path . join ( OVERRIDES_DIR , 'js' , 'prepend-node.js' ) ;
14
16
const NODE_OPTION = `--require ${
15
17
// Avoid quoting except when necessary, because node 8 doesn't support quotes here
@@ -27,6 +29,10 @@ export function getTerminalEnvVars(
27
29
) : { [ key : string ] : string } {
28
30
const proxyUrl = `http://127.0.0.1:${ proxyPort } ` ;
29
31
32
+ const javaAgentOption = `-javaagent:${
33
+ OVERRIDE_JAVA_AGENT
34
+ } =127.0.0.1|${ proxyPort } |${ httpsConfig . certPath } `;
35
+
30
36
return {
31
37
'http_proxy' : proxyUrl ,
32
38
'HTTP_PROXY' : proxyUrl ,
@@ -84,6 +90,13 @@ export function getTerminalEnvVars(
84
90
// subprocesses. Otherwise e.g. --max-http-header-size breaks old Node/Electron.
85
91
'NODE_OPTIONS' : currentEnv === 'runtime-inherit'
86
92
? `$NODE_OPTIONS ${ NODE_OPTION } `
87
- : NODE_OPTION
93
+ : NODE_OPTION ,
94
+
95
+ // Attach our Java agent to all launched Java processes:
96
+ 'JAVA_TOOL_OPTIONS' : currentEnv === 'runtime-inherit'
97
+ ? `$JAVA_TOOL_OPTIONS ${ javaAgentOption } `
98
+ : currentEnv . JAVA_TOOL_OPTIONS
99
+ ? `${ currentEnv . JAVA_TOOL_OPTIONS } ${ javaAgentOption } `
100
+ : javaAgentOption
88
101
} ;
89
102
}
0 commit comments