Issue 1267 fix: jbp config java main#1268
Conversation
…ring Boot
The registry stopped at Spring Boot (highest priority) without ever calling
JavaMainContainer.Detect(). If java_main_class is set in JBP_CONFIG_JAVA_MAIN,
select Java Main unconditionally before the normal detection loop, so it can
override higher-priority containers such as Spring Boot.
Also adds Ruby parity for SERVER_PORT: when java_main_class is a Spring Boot
launcher (JarLauncher, PropertiesLauncher, WarLauncher), write SERVER_PORT=$PORT
to profile.d so the app binds to the CF-assigned port.
Example use case:
JBP_CONFIG_JAVA_MAIN: '{java_main_class: "org.springframework.boot.loader.launch.PropertiesLauncher", arguments: "--loader.home=/home/vcap/data"}'
Updates container-java_main.md: references JBP_CONFIG_JAVA_MAIN instead of
config/java_main.yml, corrects SERVER_PORT behaviour, adds example.
kiril-keranov
left a comment
There was a problem hiding this comment.
looks good, left minor suggestion for possible optimization
| func (r *Registry) Detect() (Container, string, error) { | ||
| cfg := loadJavaMainConfig(r.context.Log) | ||
| if cfg.JavaMainClass != "" { | ||
| for _, container := range r.containers { |
There was a problem hiding this comment.
seems this loop might be omit if we rely on the current order that the java main container is with least priority like currently here. If for some reason these container priorities change or a new container is introduced after the java main there will be failing tests like selects Java Main container instead of Spring Boot signaling this to change, also seems no major container priorities reordering or addition of new containers are expected I guess
There was a problem hiding this comment.
@kiril-keranov Thanks for the review. Assuming the java main is last if available now... if java main not found but there is a configuration line, a warning is given.
JavaMain is always registered last, so use r.containers[len-1] with a type assertion instead of scanning all containers. Warn if the last element is not a JavaMainContainer.
Also added some notes on why the integration test did not find the missing arguments and command line changes.
Fixes #1267