如何在重新部署之前使用 maven-as 插件重新启动 JBoss



我在尝试设置 maven 作为插件时遇到了头痛。

我的目标是在运行集成测试之前重新部署耳朵。我希望此过程是自动的,以将其集成到CI中。

该服务器是远程运行的 JBoss 服务器 (AS 7)。

由于 Jboss 臭名昭著的 PermGen 空间问题,我需要在之前重新启动服务器展开耳朵。否则,服务器将每 5 次运行左右爆炸一次......

为此,我尝试设置一个目标"关闭",reload=true。问题是 maven 插件不会等待它完成,然后再运行下一个目标(清理以前的工件)。

这是我的POM的摘录:

      <!-- Jboss Deploy/undeploy application EAR -->
      <plugin>
        <groupId>org.jboss.as.plugins</groupId>
        <artifactId>jboss-as-maven-plugin</artifactId>
        <version>7.5.Final</version>
        <configuration>
          <!-- JBoss management -->
          <hostname>${sanity.tests.jboss.host}</hostname>
          <port>${sanity.tests.management.port}</port>
          <username>${sanity.tests.jboss.username}</username>
          <password>${sanity.tests.management.password}</password>
        </configuration>
        <executions>
          <!-- Reload Jboss to avoid permgen space -->
          <execution>
            <id>restart</id>
            <phase>pre-integration-test</phase>
            <goals><goal>shutdown</goal></goals>
            <configuration>
              <reload>true</reload>
            </configuration>
          </execution> 
          <!-- Undeploy previous ear -->
          <execution>
            <id>undeploy</id>
            <phase>pre-integration-test</phase>
            <!-- Cleanup : Undeploy -->
            <goals>
              <goal>undeploy</goal>
            </goals>
            <configuration>
             <matchPattern>rm-app.*.ear</matchPattern>
              <ignoreMissingDeployment>true</ignoreMissingDeployment>
            </configuration>
          </execution>
          <!-- Deploy before int test --> 
          <execution>
            <id>deploy</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>deploy-artifact</goal>
            </goals>
            <configuration>
              <name>xxxx</name>
              <groupId>xxxxx</groupId>
              <artifactId>xxxx</artifactId>
              <version>${project.version}</version>
            </configuration> 
          </execution>
        </executions>
      </plugin>

任何帮助将不胜感激。

首先尝试运行取消部署。如果这是 AS 上唯一的耳朵,那么重新加载很可能足够快,使部署目标不会超时。

<goals>
    <goal>undeploy</goal>
    <goal>shutdown</goal>
    <goal>deploy</goal>
</goals>

不幸的是,我不知道如何增加部署目标的超时。

我遇到了完全相同的问题。 switangs 建议(在重新启动 JBoss 之前先取消部署)肯定会有所帮助。为了在服务器重新启动和重新部署之间增加一些时间,我所做的另一件事是将服务器的取消部署和重新启动绑定到构建过程的早期步骤(例如初始化),而部署步骤是绑定到进程资源或预集成测试,就像您的情况一样。这之所以有效,是因为我在一个单独的集成测试模块中部署了我的工件,该模块首先将所有相关的服务器工件与 maven-dependency-plugin 插件复制到 ${project.build.directory}/dependency 文件夹中,作为第一步。但我同意这不是一个非常好的解决方案,为独立的 JBoss 节点阻止重启 cli 命令会好得多。

事实上,关闭目标并不能解决PermGen问题。我通过使用 cli 解决了这个问题。

<plugin>
    <groupId>org.jboss.as.plugins</groupId>
    <artifactId>jboss-as-maven-plugin</artifactId>
    <version>7.5.Final</version>
    <configuration>
        <afterDeployment>
            <commands>
                <command>/host=master:shutdown(restart=true)</command>
            </commands>
        </afterDeployment>
    <!-- your configuration -->
    ...
    </configuration>
<plugin>

而"master"是域模式下的主机名称。

最新更新