我目前正在编写一个 Java 守护进程。我正在编写一个包含标准守护进程命令(启动、停止、重新启动、状态)的脚本,并且我试图决定安装守护进程时应该进行的操作。
我目前的想法是:
PID 文件: /var/run/myapp.pid
守护进程脚本: /etc/init.d/myapp
Java 应用程序 (.jar): /usr/bin/myapp
日志: /var/log/myapp.err、/var/log/myapp.log、/var/log/myapp .info(你明白了)
配置: /etc/myapp.conf (或者 /etc/myapp/configs-go-here 如果我将来有多个配置) )
我对 Linux 目录结构还很陌生,所以如果我做错了什么,请告诉我。最让我困惑的是我的 Java 应用程序是一个 .jar 文件(存档)而不是二进制文件。那么这是否意味着 /usr/bin/ 不是它的“正确”位置?
I'm currently writing a Java daemon. I'm writing a script that will have the standard daemon commands (start, stop, restart, status) and I'm trying to decide on where things should go when installing the daemon.
My current idea is:
PID File: /var/run/myapp.pid
Daemon Script: /etc/init.d/myapp
Java App (.jar): /usr/bin/myapp
Logs: /var/log/myapp.err, /var/log/myapp.log, /var/log/myapp.info (you get the idea)
Configs: /etc/myapp.conf (or /etc/myapp/configs-go-here if I have more than one in the future)
I'm still new to the Linux directory structure so if I'm doing something wrong let me know. Whats confusing me the most is that my Java app is a .jar file (archive) and not a binary. So does that mean that /usr/bin/ isn't the "right" place for it?
发布评论
评论(2)
您可以将
.jar
文件放在/usr/lib/myapp/myapp.jar
中,并使启动脚本执行java -j /usr/lib/myapp /myapp.jar
从侧面看,该 jar 实际上是
/usr/bin/java
二进制文件使用的一个库,因此这些位置对我来说看起来不错。You could put the
.jar
file in/usr/lib/myapp/myapp.jar
and make the startup script dojava -j /usr/lib/myapp/myapp.jar
Looking it from that side, the jar is effectively a library that the
/usr/bin/java
binary uses, so those locations look good to me./usr/lib/myapp/myapp.jar
建议是正确的,但是/usr/lib
适用于特定于体系结构的文件 - 因为 Javajar
档案与平台无关,/usr/share/myapp/myapp.jar
是更好的位置。The
/usr/lib/myapp/myapp.jar
suggestion is on the right track, but/usr/lib
is for architecture-specific files - since Javajar
archives are platform-independent,/usr/share/myapp/myapp.jar
is a better location.