I'm converting a Java REST service from the 'traditional' way -- as a servlet compliant .war that deploys to a multi-tenant app server (Tomcat) -- to a much simpler embedded setup where there is a simple Java main class that starts an embedded http server (Grizzly+Jersey). The one missing piece is the service wrapper. I can manually run the service by doing 'java -jar myservice.jar', but I'd like to implement as a proper Linux background service.
Normally, this is done with a simple Bash shell script that you put in /etc/init.d. I've seen some super simple examples, but they implement shutdown with a process kill rather than a graceful shutdown. I've also seen some commerical tools to handle this, but this task seems way too simple to involve a commerical tool.
My first guess would be to add a separate super simple REST service on a second port that listens for shutdown requests and have the /etc/init.d Bash shell script send shutdown requests that way.
Are there better or more standard solutions to this issue?