Finalize adds JMX options to JAVA_OPTS via profile.d script
()
| 49 | |
| 50 | // Finalize adds JMX options to JAVA_OPTS via profile.d script |
| 51 | func (j *JmxFramework) Finalize() error { |
| 52 | config, err := j.loadConfig() |
| 53 | if err != nil { |
| 54 | j.context.Log.Warning("Failed to load debug config: %s", err.Error()) |
| 55 | return nil // Don't fail the build |
| 56 | } |
| 57 | |
| 58 | port := config.getPort() |
| 59 | |
| 60 | // Build JMX system properties |
| 61 | jmxOpts := fmt.Sprintf( |
| 62 | "-Djava.rmi.server.hostname=127.0.0.1 "+ |
| 63 | "-Dcom.sun.management.jmxremote.authenticate=false "+ |
| 64 | "-Dcom.sun.management.jmxremote.ssl=false "+ |
| 65 | "-Dcom.sun.management.jmxremote.port=%d "+ |
| 66 | "-Dcom.sun.management.jmxremote.rmi.port=%d", |
| 67 | port, port, |
| 68 | ) |
| 69 | |
| 70 | // Write JAVA_OPTS to .opts file with priority 29 (Ruby buildpack line 63) |
| 71 | if err := writeJavaOptsFile(j.context, 29, "jmx", jmxOpts); err != nil { |
| 72 | return fmt.Errorf("failed to write java_opts file: %w", err) |
| 73 | } |
| 74 | |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | func (j *JmxFramework) loadConfig() (*jmxConfig, error) { |
| 79 | // initialize default values |
nothing calls this directly
no test coverage detected