Command line args and Java Buildpack

1,383 views
Skip to first unread message

John McTeague

unread,
Jan 5, 2015, 6:26:15 AM1/5/15
to vcap...@cloudfoundry.org
The Java buildpack docs at https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-java_main.md contains the following statement:

"Command line arguments may optionally be configured."

However I cannot figure out how they are supposed to be passed to the app at point of push (manifest of CLI arg), can someone fill me in? Is it by overriding the start command? If so, do I need to completely replace the generated command that the buildpack creates (with the full path to the java binary, memory settings etc)?

Thanks,
John

James Bayer

unread,
Jan 5, 2015, 9:35:04 AM1/5/15
to vcap...@cloudfoundry.org
i know that JAVA_OPTS are picked up from env vars, although some are restricted [1].

one way you can find the start command for an app named 'java-debug' is like this:
 cf curl /v2/apps/`cf app java-debug --guid`/summary | grep 'detected_start_command'
   "detected_start_command": "JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS=\"-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -Xmx768M -Xms768M -XX:MaxMetaspaceSize=104857K -XX:MetaspaceSize=104857K -Xss1M -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n -Daccess.logging.enabled=false -Dhttp.port=$PORT\" $PWD/.java-buildpack/tomcat/bin/catalina.sh run"

then you can change the start command like this:
cf curl /v2/apps/`cf app java-debug --guid` -X PUT -d "{ \"command\":\"whatever your start command would be\"}"

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/0092f3f7-c41d-472d-8c5d-9a30bff7cee2%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer

sparam...@pivotal.io

unread,
Jan 5, 2015, 2:42:06 PM1/5/15
to vcap...@cloudfoundry.org
You can either use the set-env option or via the manifest to set JAVA_OPTS env variable which in turn would be used by the java buildpack while kicking off the app instance.

Example via set-env:

  cf set-env MyApp JAVA_OPTS "-Djava.net.preferIpv4=true  -XX:-DisableExplicitGC -Djava.security.egd=file:/dev/./urandom"

-- this requires the app to be already pushed and then setting the environment variable. One way would be to push the app with nostart option and then set the variables and then start finally.

Or via the manifest file during app push:

     path: build/libs/test-broker-0.1.0.jar
     env:
       JAVA_OPTS : "-Duser.timezone=GMT"


-Sabha
Reply all
Reply to author
Forward
0 new messages