Re: Deploying a shell script driven java application to cf


Daniel Mikusa
 

I haven't tried this, but I think it should work.

1.) Make a directory. In that directory put your JAR file, your start
script and anything else the app needs to run.
2.) From that directory, run `cf push <app-name> -b java_buildpack -c
'$PWD/start-script.sh'`. This will upload your script, the JAR file and
everything else in the current directory. It will also tell CF that you
specifically want to use the Java build pack (which will install Java) and
that you want to use your script to start your app.

What could be tricky about this is your start script. It's going to need
to reference JAVA_HOME as `/home/vcap/app/.java-buildpack/open_jdk_jre`,
and `java` as `$JAVA_HOME/bin/java` since `java` is not going to be on the
$PATH.

You're also going to need to handle some of the things that the JBP would
normally do like set -Xmx and other JVM memory settings to keep the JVM
from exceeding the containers MEMORY_LIMIT. Note, *all* memory needs to
fit under the limit, not just the JVM's heap. In other words, setting -Xmx
== MEMORY_LIMIT is 100% wrong.

Beyond that, you'd need to make sure the app is listening on $PORT or if
it's not taking web requests, disable that health check (`cf push
--no-route` & `cf set-health-check none`).

Dan

On Fri, Nov 13, 2015 at 12:47 AM, dammina sahabandu <dammina(a)adroitlogic.com
wrote:
Hi All,
I have a java application which is a composition of several jars in the
running environment. The main jar is invoked by a shell script. Is it
possible to push such application into cloud foundry? And if it is possible
can you please help me on how to achieve that. A simple guide will be
really helpful.

Thank you in advance,
Dammina

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.