如何将现有 Java 应用程序转换为 SYS V 服务(守护程序) [英] How to convert an existing Java application to a SYS V service (daemon)
问题描述
我有一个 Java 应用程序,我使用它来启动它
I have a Java application, to start it I use
java -jar myapp.jar
java -jar myapp.jar
要停止它,我使用 CTRL+C.
To stop it I use CTRL+C.
现在我需要将该应用程序转换为我可以开始使用的内容:
Now I need to convert that application to something that I can start with:
/etc/init.d/myapp start
/etc/init.d/myapp start
我可以停止:
/etc/init.d/myapp 停止
/etc/init.d/myapp stop
问题在于保存进程的 PID,我想我在某处看到了这样做的方法,我不记得在哪里,也找不到.
The problem is all about saving the PID of the process, I think I saw somewhere a recipe for doing this, I don't remember where and I'm not able to find it.
我看到有一个名为 Java Server Wrapper 的项目,但我寻找不限制内存使用的免费内容.而且我认为这项工作可以在单个 bash 脚本中完成.
I saw that there is a project called Java Server Wrapper, but I look for something free that does not limit memory usage. And I think that this work could be done in a single bash script.
推荐答案
它具有jsvc"启动器,支持启动和停止基于 Java 的守护进程(服务).
It has 'jsvc' launcher which suports starting and stopping java-based daemons (services).
这篇关于如何将现有 Java 应用程序转换为 SYS V 服务(守护程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!