Java守护程序部署 [英] Java daemon deployment

查看:218
本文介绍了Java守护程序部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台Java应用程序,它一直在远程服务器上运行(nohup java -jar myapp.jar&)。



经常(其他所有人)我需要更换一个更新的JAR文件(每当我修复一个缺陷时)。



目前我通过使用ssh连接到服务器来实现这一点( WinSCP)。



我如何创建一种机制,使用它可以通过http协议升级应用程序?我可以使用JMX吗?



该机制应该做以下事情:



a)停止当前运行b。将bAR文件上传到服务器。



c)启动新的JAR文件。

解决方案

基本上你需要将程序分为两部分:


  1. 监视器组件,它获取新jar,停止程序,替换jar,重新启动程序


  2. 实际程序,控制台java应用程序


理论上你可以在一个java进程中完成所有这些工作,但在我看来额外的复杂性并不值得。


I have a console Java application, which runs all the time on a remote server (nohup java -jar myapp.jar &).

Frequently (every other day) I need to replace the JAR file by a newer one (whenever I fix a defect).

At the moment I do this by connecting to the server using ssh (WinSCP).

How can I create a mechanism, using which I could upgrade the application via the http protocol? Can I use JMX for that?

That mechanism should do following things:

a) Stop the currently running application.

b) Upload the new JAR file to the server.

c) Launch the new JAR file.

解决方案

Basically you need to break down the program into two parts:

  1. the monitor component which fetches the new jar, stops the program, replaces the jar, restarts the program

  2. the actual program, the console java application

Theoretically you can do all of this in a single java process but the additional complexity is not worth the trouble in my opinion.

这篇关于Java守护程序部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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