JSVC 初始化脚本不退出
我正在尝试使用 jsvc 对我的 Java 应用程序进行去恶魔化。这是我的初始化脚本
#!/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
当我以 root 身份运行 ./thisscript.sh start
时,有两件事出了问题,我怀疑它们是相关的:
- 应用程序启动,但显示其输出而不是保存到指定的位置outfile
- 脚本不会退出,但会阻塞,直到我按
Ctrl+C
。
我做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有看到你的启动脚本有什么问题;也许您的服务实现
DeamonGameServer
存在问题。尝试用简单的守护进程框架实现替换您的类,看看会发生什么。另外,请注意
jsrv
中存在一个开放缺陷:Jsvc 不当所有非守护线程都死掉时退出。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.