Install4J -> 如何以编程方式对服务进行无头更新

问题描述 投票:0回答:1

我编写了一个非常简单的演示项目,它有一个后台服务,该服务仅运行一个可以处理 CLI 命令的 telnet 服务器,以便我可以弄清楚如何进行编程式无头更新。问题似乎有两个方面:首先,如何配置安装程序项目,以便我有一个用于最初安装服务的 GUI 安装程序,其次,安装后,我需要执行哪些 API 调用才能执行以下操作:无头更新。

我编写了以下可以通过应用程序 CLI 执行的命令:

   @Command(abbreviation = "updateChecker")
    public String updateChecker() {
        try {
            final String updateUrl = Variables.getCompilerVariable("sys.updatesUrl");
            final UpdateDescriptor updateDescriptor = UpdateChecker.getUpdateDescriptor(updateUrl, ApplicationDisplayMode.UNATTENDED);
            if (updateDescriptor.getPossibleUpdateEntry() != null) {
                return updateDescriptor.getPossibleUpdateEntry().getFileName();
            } else {
                return "No update";
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Command(abbreviation = "isUpdateScheduled")
    public String isUpdateScheduled() {
        try {
            final String updateUrl = Variables.getCompilerVariable("sys.updatesUrl");
            if (UpdateChecker.isUpdateScheduled()) {
                return "true";
            } else {
                return "false";
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Command(abbreviation = "executeScheduledUpdate")
    public void executeScheduledUpdate() {
        try {
            final String updateUrl = Variables.getCompilerVariable("sys.updatesUrl");
            UpdateChecker.executeScheduledUpdate(null, true, null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

当我调用“updateChecker”时,我可以在我的服务器上看到新版本的安装程序文件。

当我调用“isUpdatedScheduled”时,它总是返回 false。

当我调用“executeScheduledUpdate”时,它什么也不做。

service install4j headless
1个回答
0
投票

当我调用“isUpdatedScheduled”时,它总是返回 false。 当我调用“executeScheduledUpdate”时,它什么也不做。

更新由后台更新下载程序“安排”。您可以在“安装程序”->“屏幕和操作”步骤中将后台更新下载程序添加到您的项目中。请参阅后台更新程序的“启动器集成”选项卡,了解如何从您的服务以编程方式启动它。

此处解释了后台更新的概念。您可以查看“hello”示例应用程序,了解如何以编程方式调用后台更新程序并执行计划更新。

© www.soinside.com 2019 - 2024. All rights reserved.