【发布时间】:2014-04-08 17:44:09
【问题描述】:
我必须通过按钮操作调用 php“build.php”,然后 php 将调用 python 脚本并应立即返回。
动作:
<form method="get" action="build.php">
<input type="hidden" name="branch" value="master">
<input type="submit" value="Build Master" id="btnMaster">
</form>
build.php
<?php
if(isset($_GET['branch']))
{
$output = shell_exec('/usr/bin/python /Users/testuser/gitroot/buildOnGuest.py --dest /Users/testuser/Builds --branch ' . $_GET['branch'] . ' 2>&1 &');
}
elseif (isset($_GET['tag']))
{
$output = shell_exec('/usr/bin/python /Users/testuser/gitroot/buildOnGuest.py --dest /Users/testuser/Builds --tag ' . $_GET['tag'] . ' 2>&1 &');
}
?>
所以python脚本在后台(&)执行,php应该立即返回到主页面。有可能吗?如何实现?
【问题讨论】:
-
什么意思是立即返回.. 性能问题?
-
如果你的意思是重定向,check this
-
尝试重定向
shell_exec中命令的标准输出。 -
不,只是我想返回主页而不是等待构建(需要1个多小时)。主页应该只调用构建脚本而不是去 build.php。