I am trying to design a graceful startup/shutdown script (Bash) for a Java app (JAR) that I will be deploying to my Ubuntu 14.04 server. I'm looking for a clean, Linux- and Ubuntu-friendly way of starting the server like so:
java -jar myapp.jar <lots off subsequent arguments>
And then, in the shutdown script, finding the JAR's PID, issuing a SIGSTOP to allow the app to do a graceful shutdown on its own, and then finally killing the PID when its good and ready.
I looked at how Tomcat handles this with its own catalina.sh
and was surprised to find it wasn't doing too much other magic under the hood then simply killing a PID.
I was wondering if upstart
may be a good candidate for such a use case, and if so, how? Otherwise, what are some other approaches that I might be able to take? Any other Linux/Ubuntu facilities/tools/programs out there that I should consider?