I'm trying to deploy an Java app onto VPS. I'm using Gradle build system with 'application' plugin. I want the app to start up with the server.
During deployment process I run ./gradlew install
to prepare run scripts. When ran directly, they work properly.
I used http://www.whiteboardcoder.com/2014/02/ubuntu-upstart-job-with-java-jar.html as a base for upstart configuration:
description "the test server"
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
script
cd /opt/testserver/
exec ./build/install/testserver/bin/testserver
end script
But the PID reported by upstart after running start testserver
is different then the one found using ps
. My guess is that the reason for that is the last line of generated script:
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" mypackage.TestServer"$@"
As a result Upstart is not able to stop the app. Is there a way to make upstart see the right PID?
Well it looks like there is no forking going on here, so you should try removing the expect fork
bit.