Java daemon deployment

寵の児 提交于 2020-01-13 07:03:33

问题


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.


回答1:


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.




回答2:


You might check out install4j or this similar StackOverflow question.




回答3:


In LiveRebel, there's native support for standalone applications (i.e. daemons). So the main application is running with the watchdog agent which communicates to the command center. From command center it is possible then to manage the updates.



来源:https://stackoverflow.com/questions/7767001/java-daemon-deployment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!