【发布时间】:2016-09-22 11:15:52
【问题描述】:
我想在 Phing 中运行一个任务,我首先运行 PHP 服务器,然后运行 PHP 单元测试。
这是我目前所拥有的:
<target name="test">
<!-- Run the PHP server -->
<exec executable="php">
<arg line="-S localhost:81 server.php"/>
</exec>
<!-- Run my tests -->
<exec executable="${phpunit.bin}" dir="${test.dir}" passthru="true" returnProperty="test.result">
<arg line="IntegrationTests"/>
</exec>
<!-- Check if succeeded -->
<condition property="test.succeeded">
<equals arg1="${test.result}" arg2="0"/>
</condition>
<fail unless="test.succeeded" message="Unit Tests Failed"/>
</target>
问题是 Phing 在创建 PHP 服务器后挂起。
通过像这样添加 spawn 属性解决了这个问题:
<exec executable="php" spawn="true">
这按预期工作,只是即使在 Phing 退出后进程也不会真正退出。换句话说,PHP 服务器在 Phing 完成它的任务后仍然运行很长时间。
因此我的问题是如何在 Phing 的后台正确运行 php 服务器?
【问题讨论】: