且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Linux上守护Java应用程序的***方法

更新时间:2023-10-21 12:34:16

虽然标准答案似乎是 jsvc ,但我一直在使用djb的守护进程工具成为一个守护进程的好方法。



我有java,python和一些shell脚本都作为守护进程运行,有一个简单的启动/停止方式他们和伟大的日志记录。



我曾经在初始设计的initctl上以root身份运行daemontools本身,但几个月后我决定手动运行它,在一个普通用户,并使用 svscan-start 进行更好的日志记录。


While I found this question being answered here on SW several times, I didn't find a concluding answer what is the best approach.

I'm not looking to use any external wrapper, as I found them launching the java process under a nice level lower then themselves which potentially lowers the performance, so it seems only the shell methods are left.

I so far found 3 different shell methods:

  • start-stop-daemon
  • RedHat daemon init.d function
  • nohup on start / disown after start

What you people are using, and can recommend as the most reliable method?

Thanks.

While the standard answer to this seems to be jsvc, I have been using djb's daemon tools to be a great way to make anything into a daemon.

I have java, python and a few shell scripts all running as daemons, with a simple way to start/stop them and great logging.

I've used to run daemontools itself as root on initctl as originally designed, but after a few months I decided to run it manually, under a normal user, and using svscan-start for nicer logging.