如何使 Java 应用程序自我更新? [英] How do I make a Java app self-update?

查看:54
本文介绍了如何使 Java 应用程序自我更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我有一个独立的 Java 应用程序(以下称为代理"),它作为服务在公司内部服务器上运行.它充当某些中央服务器的远程代理.随着代理部署在更多地方,管理它们变得越来越复杂.具体来说:推送更新是痛苦的,因为它是一个相当手动的过程,并且获取有关代理运行的环境的日志和其他信息是有问题的,使得调试变得困难.讨论中的服务器是无头和无人值守的,这意味着这必须是一个完全自动化的过程,没有人工干预,因此 Java Web Start 不是一个可行的解决方案.

Problem: I have a standalone Java app (henceforth known as "the agent") that runs as a service on internal company servers. It acts as a remote agent for some central servers. As the agent gets deployed in more places, managing them is getting more complicated. Specifically: pushing updates is painful because it's a fairly manual process, and getting access to the logs and other info about the environments where the agents are running is problematic, making debugging difficult. The servers under discussion are headless and unattended, meaning that this has to be a fully automated process with no manual intervention, hence Java Web Start isn't a viable solution.

建议的解决方案:定期让座席回电话(到中央服务器)以提供座席状态并检查更新.

Proposed solution: Make the agent phone home (to the central servers) periodically to provide agent status and check for updates.

我愿意接受其他建议的问题解决方案,但我已经有了状态和自我更新"想法的工作原型,这正是本问题所关注的内容.

I'm open to other suggested solutions to the problem, but I've already got a working prototype for the "status and self-updates" idea, which is what this question is focused on.

我想出的实际上是一个单独的项目,充当代理的包装器.包装器通过 HTTP 定期调用中央服务器以检查代理的更新版本.找到更新后,它会下载新版本,关闭正在运行的代理,然后启动新的代理.如果这看起来像是一个奇怪或迂回的解决方案,这里有一些其他值得注意的注意事项/限制条件:

What I came up with is actually a separate project that acts as a wrapper for the agent. The wrapper periodically calls the central server via HTTP to check for an updated version of the agent. Upon finding an update, it downloads the new version, shuts down the running agent, and starts the new one. If that seems like an odd or roundabout solution, here are a few other considerations/constraints worth noting:

  1. 当包装器获得新版本的代理时,可能会有新的 JAR 依赖项,这意味着类路径发生变化,这意味着我可能想要生成一个单独的 Java 进程,而不是摆弄类加载器并冒着永久生成内存的风险泄漏,这将需要手动干预——正是我想要摆脱的.这就是为什么我最终使用单独的包装器"流程来管理原型中的代理更新.
  2. 部署代理的某些服务器资源有限,因此任何解决方案都需要降低 CPU 和内存使用率.这让我想要一个不涉及启动新 JVM 的解决方案,并且反对拥有单独的包装进程.
  3. 代理已经部署到 Windows 和 RHEL 服务器,因此解决方案必须是跨平台的,尽管我不会在批处理和 bash 脚本中复制合理数量的过程来使事情顺利进行.

问题:如上所述,我想知道如何制作一个自我更新的 Java 应用程序.更具体地说,是否有任何框架/库可以帮助我解决这个问题?有这方面经验的可以指点一下吗?

Question: As stated, I want to know how to make a self-updating Java app. More specifically, are there any frameworks/libraries out there that would help me with this? Can someone with experience in this area give me some pointers?

推荐答案

不同的解决方案:使用(并支付)install4j.在此处

Different solution: use (and pay for) install4j. Check out the auto-update features here

这篇关于如何使 Java 应用程序自我更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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