JSVC initscript doesn't exit
I'm trying to deamonize my Java app using jsvc. This is my initscript
#!/bin/sh
# CONFIG
JSVC=/opt/jsvc/jsvc
JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
USER=gserv
ARGS=none
# END CONFIG
PIDFILE=/var/run/silvercar-gameserver.pid
LOGDIR=/var/log/silvercar-gameserver
case "$1" in开发者_开发知识库
start)
export JAVA_HOME
cd `dirname $0`
$JSVC -jvm server -pidfile $PIDFILE -user $USER -outfile $LOGDIR/stdout -errfile $LOGDIR/stderr \
-cp `cat classpath` tr.silvercar.gameserver.runner.DeamonGameServer $ARGS
;;
stop)
$JSVC -stop -pidfile $PIDFILE
;;
esac
exit 0
When I run ./thisscript.sh start
as root two things go wrong, and I suspect they're related:
- The app starts, but its output is shown instead of saved to the specified outfile
- The script doesn't exit, but blocks until I hit
Ctrl+C
.
What am I doing wrong?
I don't see anything wrong in your launch script; perhaps there is an issue in your service implementation DeamonGameServer
. Try replacing your class with a simple Daemon skeleton implementation and see what happens.
Also, note there is an open defect in jsrv
: Jsvc does not exit when all non-daemon threads are dead.
精彩评论