Java位置编写的Linux Daemon

发布于 2024-08-12 18:21:10 字数 606 浏览 1 评论 0原文

我目前正在编写一个 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晒暮凉 2024-08-19 18:21:10

您可以将 .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 do java -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.

紫轩蝶泪 2024-08-19 18:21:10

/usr/lib/myapp/myapp.jar 建议是正确的,但是 /usr/lib 适用于特定于体系结构的文件 - 因为 Java jar 档案与平台无关,/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 Java jar archives are platform-independent, /usr/share/myapp/myapp.jar is a better location.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文