【问题标题】:Jboss 7 automatic deployment of EAR bat fileJboss 7自动部署EAR bat文件
【发布时间】:2016-11-04 04:29:33
【问题描述】:

我正在尝试在 Jboss 中自动化 EAR 的 maven 构建和部署过程。我设法为下面给出的相同编写了一个 bat 文件。

    ECHO OFF
    RMDIR /S /Q .\deploy
    call mvn clean install -D build=P,JB
    call mvn clean install -D build=F,JB
    @echo | call C:\Work\jboss-as-7.1.1.Final\bin\jboss-cli.bat --connect --controller=[my-machine-name]:9999 command=:shutdown
    del /q C:\Work\jboss-as-7.1.1.Final\standalone\deployments\*.*
    xcopy /s /y .\deploy\function\Jboss\*.ear C:\Work\jboss-as-7.1.1.Final\standalone\deployments
    xcopy /s /y .\deploy\WorkFlowEngine\Jboss\*.ear C:\Work\jboss-as-7.1.1.Final\standalone\deployments
    cd C:\Work\jboss-as-7.1.1.Final\bin
    rmdir "C:\work\jboss-as-7.1.1.Final\standalone\data" /s /q
    rmdir "C:\work\jboss-as-7.1.1.Final\standalone\log" /s /q
    rmdir "C:\work\jboss-as-7.1.1.Final\standalone\tmp" /s /q
    standalone.bat -bmanagement  [my-machine-name] -b [my-machine-name] -c standalone-full-ha.xml
      {code for check of deployment success/failure}
    PAUSE

在这里你可以看到我正在使用该行

standalone.bat -bmanagement  sbstjwsvm1509 -b sbstjwsvm1509 -c standalone-full-ha.xml

我的要求是我想从我的 bat 文件中检查 EAR 是否已成功部署。我想到的一种方法是检查 .deplyed.failed Jboss 部署文件夹中的扩展文件。我尝试为相同的代码编写代码,但我写在上述行下方的代码没有被执行。有没有其他方法可以实现这一点?或者我在做什么我的 bat 文件出错了?为什么我检查部署的代码没有被执行?

【问题讨论】:

    标签: batch-file jboss7.x


    【解决方案1】:

    因为standalone.bat 不在后台执行,并且会运行JBoss 实例,直到您杀死/停止它(ctrl+C 信号或像您通过jboss CLI 关闭)。请参阅this answer 以获取有关您想要实现的示例和详细信息。

    由于您使用的是maven,我建议您使用jboss-as-maven-plugin。 查看用法,您会发现部署/取消部署应用程序、资源以及启动/停止服务器的命令。

    然后您可以集成插件执行以在 Maven 清理阶段停止/清理,并使用目标在 Maven 安装阶段部署/启动。查看复杂示例。

    【讨论】:

      【解决方案2】:

      想在这里发布我的解决方案。

      ECHO OFF
      SET "JBOSS_DIR=C:\Work\jboss-as-7.1.1.Final"
      SET "deployedAPP=MyApp.ear"
      RMDIR /S /Q .\deploy
      call mvn clean install -D build=P,JB
      call mvn clean install -D build=F,JB
      @echo | call %JBOSS_DIR%\bin\jboss-cli.bat --connect --controller=[mymachine_name]:9999 command=:shutdown
      del /q %JBOSS_DIR%\standalone\deployments\*.*
      xcopy /s /y .\deploy\function\Jboss\*.ear %JBOSS_DIR%\standalone\deployments
      xcopy /s /y .\deploy\WorkFlowEngine\Jboss\*.ear %JBOSS_DIR%\standalone\deployments
      cd %JBOSS_DIR%\bin
      PING -n 61 -w 1 localhost >nul
      START CMD /C CALL MyJboss.bat
      SET count=0
      :checkIfDeployed
          if exist "%JBOSS_DIR%\standalone\deployments\%deployedAPP%.deployed" (
              GOTO appDeployed
          )
          if exist "%JBOSS_DIR%\standalone\deployments\%deployedAPP%.failed" (
              GOTO deployFailed
          )
          PING -n 6 -w 1 localhost >nul
              GOTO checkIfDeployed
      :appDeployed
          PAUSE
          EXIT
      :deployFailed
          SET /A count+=1
          if %count% == 5 ( goto end )
          @echo | call %JBOSS_DIR%\bin\jboss-cli.bat --connect --controller=[mymachine_name]:9999 command=:shutdown
          PING -n 61 -w 1 localhost >nul
          START CMD /C CALL MyJboss.bat
          GOTO checkIfDeployed
      :end
          PAUSE
      

      用线

      START CMD /C CALL MyJboss.bat
      

      在另一个 cmd 窗口中启动 JBoss。现在我下面的所有代码都将被执行。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-27
        • 2012-11-15
        • 2019-01-29
        • 1970-01-01
        • 1970-01-01
        • 2020-05-14
        • 1970-01-01
        • 2021-10-30
        相关资源
        最近更新 更多