开发者

Java daemon deployment

开发者 https://www.devze.com 2023-04-12 20:05 出处:网络
I have a console Java application, which runs all the time on a remote server (nohup java -jar myapp.jar &).

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 (Wi开发者_JAVA技巧nSCP).

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.


You might check out install4j or this similar StackOverflow question.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消