Linux上的Java服务 - 如何确保持续的正常运行时间。 Deamon,Shell脚本或Wrapper? [英] Java service on Linux - How to ensure constant uptime. Deamon, Shell script or Wrapper?

查看:247
本文介绍了Linux上的Java服务 - 如何确保持续的正常运行时间。 Deamon,Shell脚本或Wrapper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java工作人员通过Web服务调用轮询外部队列系统的作业。

I have a Java worker that are polling a external queue system for jobs, through web service calls.

确保工作人员的最可靠方法是什么在任何给定时间运行?

What is the most solid way to ensure that the worker is operating at any given time?

推荐答案

JVM执行与任何其他程序没有什么不同。所以你想要做的是将一个shell脚本放在一起并放在/etc/init.d中并将它适当地链接到/etc/rc.d。在RedHat风格上,它将确保服务启动系统。

JVM execution is not different from any other program. So what you want to do is to put together a shell script and place it in /etc/init.d and link it appropriatelly to to /etc/rc.d. On RedHat flavors it will ensure service startup with the system.

拧干脚本可能很棘手,但我会复制一个现有的并将其更改为调用java可执行文件正确的参数。在此脚本中,您必须捕获java进程ID。您可以使用它来监控您的过程并根据需要重新启动。

Wring the script may be tricky, but I would copy one of existing ones and change it to call java executable with right parameters. In this script you would have to capture java process id. You can use it then to monitor your process and restart as necessary.

这篇关于Linux上的Java服务 - 如何确保持续的正常运行时间。 Deamon,Shell脚本或Wrapper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆