简体   繁体   English

如何使用Jsvc将Java程序作为守护程序启动

[英]How to start Java program as a daemon using Jsvc

I am using Jsvc to start a java program that implements the Daemon interface. 我正在使用Jsvc启动一个实现Daemon接口的java程序。 However when I issue the command 但是当我发出命令时

/usr/bin/jsvc -user walikha -home $JAVE_HOME -outfile out.file -errfile '$1'   Jooist.Server.jar Main

However the command silently executes and displays the prompt. 但是,命令以静默方式执行并显示提示。 How can I detect if the daemon is running? 如何检测守护程序是否正在运行? In the Java executable the init, start, stop and destroy functions just print to a log file using Log4J. 在Java可执行文件中,init,start,stop和destroy函数只是使用Log4J打印到日志文件。 The log file is not created and there is absolutely no indication that the service is running. 未创建日志文件,并且绝对没有迹象表明该服务正在运行。 Am I missing something, or have I left out something when configuring and installing Jsvc? 我错过了什么,或者在配置和安装Jsvc时遗漏了什么?

修改命令以包含选项“-outfile”和“-errfile”,并提供自己的日志文件路径。

/usr/bin/jsvc -outfile app.out -errfile app.err -user walikha -home $JAVE_HOME -outfile out.file -errfile '$1'   Jooist.Server.jar Main

Try the -debug switch and see what's going on. 尝试-debug开关,看看发生了什么。 However, it looks like you've missed including commons-daemon-1.0.10.jar in your classpath. 但是,您似乎错过了在类路径中包含commons-daemon-1.0.10.jar

您可以通过在/etc/init.d/ start/stop脚本中添加应用程序来启动服务作为守护程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM