【问题标题】:maven ant run plugin - killing process that was spawnedmaven ant run plugin - 杀死产生的进程
【发布时间】:2016-05-05 13:50:30
【问题描述】:

谁能告诉我是否可以生成一个进程,然后在集成测试完成运行时终止该进程?

我目前正在使用 ant run 插件来启动 grunt 连接服务器,并且我正在使用 cargo 将我的 rest 应用程序部署到 tomcat,这允许我对正在运行的调用 rest 服务的 angular web 应用程序进行集成测试。

我几乎拥有了我想要的一切,但是.. 构建完成后,grunt 服务器仍在运行,因为我已将 keep alive 设置为 true。

理想情况下,当我的构建完成时,我想以某种方式终止服务器的进程。

【问题讨论】:

  • 类似这样的东西:stackoverflow.com/questions/35453479/…?
  • 可能,但我没有生成 java 进程,我实际上是在生成一个 cmd 或 shell,然后使用它来启动启动服务器的 grunt 脚本。你也可以用它来杀死命令提示符吗?

标签: maven maven-antrun-plugin grunt-connect


【解决方案1】:

当我的构建在 maven 中运行时,我回到这个作为我需要修复的最后一部分,以便让我的多模块项目构建和运行针对角度前端和 java 后端的集成测试。

杀死生成的节点服务器的最后一件事是使用 ant run 插件来杀死它(真的很简单!)。

无论如何,这可能会在未来对其他人有所帮助:

   <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>Run grunt integration-test task in pre-integration-test phase</id>
                    <phase>pre-integration-test</phase>
                    <configuration>
                        <target name="starting">
                            <echo>

                            </echo>
                            <exec executable="cmd" spawn="true" dir="${project.basedir}"
                                osfamily="windows">
                                <arg line="/c grunt int-test --no-color > grunt.status " />
                            </exec>
                            <exec executable="bash" spawn="true" dir="${project.basedir}"
                                osfamily="unix">
                                <arg line="grunt int-test --no-color > grunt.status" />
                            </exec>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>                            
                <execution>
                    <id>Kill NodeServer in post-integration-test phase</id>
                    <phase>post-integration-test</phase>
                    <configuration>
                        <target name="ending">
                            <echo>

                            </echo>
                            <exec executable="cmd" spawn="true" dir="${project.basedir}"
                                osfamily="windows">
                                <arg line="/c Taskkill /IM node.exe /F " />
                            </exec>
                            <exec executable="bash" spawn="true" dir="${project.basedir}"
                                osfamily="unix">
                                <arg line="kill -9 $(ps aux | grep '\snode\s' | awk '{print $2}')" />
                            </exec>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多