I am using a native compiled jsvc to launch a java daemon. I am running this on an openSUSE 32 bit vm. The code implements Apache's daemon interface, and I'm executing the deamon with the following command.
./jsvc -home jre -errfile logs/jsvc.err -pidfile daemon.pid -cp <my_classpath> com.loader.loaderservice.LoaderDaemon
It starts and runs without a problem. I can start the daemon as a normal user and as root. However, when I go to terminate the daemon, jsvc kills the process rather than issuing a stop command.
./jsvc -stop -home jre -outfile logs/jsvc.err -errfile logs/jsvc.err -pidfile daemon.pid -cp <my_classpath> com.loader.loaderservice.LoaderDaemon
The daemon process dies, but does not execute any of its shutdown steps (for example, it should log, mark a record in the db, etc). I get the following in the logs/jsvc.err file, and it doesn't write any other logs:
Service exit with return value 143
After googling the error, I'm seeing a handful of people who all have seen the same thing, but nowhere can I find a good resolution (http://mail-archives.apache.org/mod_mbox/commons-dev/200401.mbox/%3CPine.GSO.3.96.1040105133739.23375A-100000@merlot.tel.uva.es%3E, http://www.tek-tips.com/viewthread.cfm?qid=1014679, http://threebit.net/mail-archive/tomcat-users/msg03832.html).
UPDATE: Using Apache's window's service launcher (procrun) I am able to start and stop the service without any problems. The problem appears to be only jsvc related, and only on stopping the daemon.
UPDATE 2: After reading the http://commons.apache.org/daemon/jsvc.html#Starting_jsvc more carefully, I noticed that the stop tag I'm using issues a kill command pn the process via the pid file I specify. It seems that jsvc doesn't actually stop the daemon gracefully by design. This is consistent with the behavior I'm seeing, as the very verbose stop method isn't writing any messages out.
-stop stop the service using the file given in the -pidfile option
New Questions:
- If my java main has implemented the Apache Daemon interface, how do I issue a 'stop' on the running daemon?
- Do I need something other than jsvc (which seems like it's only useful for starting or killing the daemon)?