0

プロセスを生成し、統合テストの実行が終了したときにそのプロセスを強制終了することが可能かどうか誰か教えてもらえますか?

私は現在、ant run プラグインを使用して grunt Connect サーバーを起動しており、cargo を使用して残りのアプリを tomcat にデプロイしています。これにより、残りのサービスを呼び出す実行中の angular Web アプリに対して統合テストを行うことができます。

私はほとんどすべてを希望どおりに持っていますが、ビルドが終了しても、キープアライブをtrueに設定しているため、gruntサーバーはまだ実行されています。

理想的には、ビルドが終了したら、サーバーのプロセスを何らかの方法で強制終了したいと考えています。

4

1 に答える 1

0

マルチモジュール プロジェクトをビルドし、ビルドを maven で実行するときに角度のあるフロント エンドと Java バック エンドに対して統合テストを実行するために修正する必要がある最後の部分として、これに戻ってきました。

生成されたノード サーバーを強制終了するために最後に行うことは、ant 実行プラグインを使用してそれを強制終了することです (非常に簡単です!)。

とにかく、これが将来誰かを助けるかもしれないことを願っています:

   <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>
于 2016-05-25T11:19:33.190 に答える