iis 7 - PHP 脚本挂起,即使设置了 max_execution_time 和 IIS7 连接超时


iis 7 - PHP Script hangs even though max_execution_time & IIS7 Connection Timeout is set

即使在后台进程完成运行后,我的PHP脚本"挂起"也遇到了一个非常奇怪的问题。我正在运行PHP 5.3,Windows Server 2008 R2,IIS7,安装了Tomcat Apache。

项目背景 我的脚本通过"shell_exec()"函数生成PDF表单。可以生成 1 - 3,000 个表单之间的任何地方。生成所有表单后,下载链接和"重新开始"链接应该显示在页面底部 - 相反,站点继续"加载"并且链接永远不会显示 - 即使我检查服务器并看到所有文件都已完成生成。

此问题仅在生成300 +表单时出现,需要3-6分钟。

我将php.ini的"max_execution_time"设置为1200(20分钟),IIS7的"连接超时"也设置为1200秒。以下是这些设置图片的链接,以确认我已正确设置它们:http://i49.tinypic.com/15gavew.png -- php.inihttp://i49.tinypic.com/9u5j0n.png -- IIS7

我是否缺少其他设置?是否有我不知道的Tomcat Apache连接超时设置?除了"max_execution_time"和"set_time_out"之外,PHP 还有其他"超时"设置吗?我已经用尽了我的资源,并且不知道为什么我的脚本继续挂起,即使在"while 循环"完成运行并且所有 PDF 都已成功创建之后。

感谢您的任何帮助/建议。

虽然循环代码

/* build zip & directory for PDFs */
$zip = new ZipArchive;
$time = microtime(true);
    $new_dir = "c:/pdfgenerator/f-$time";
    if(!file_exists($new_dir)) {
      mkdir($new_dir);
    }

$res = $zip->open("pdf/tmppdf/mf-pdfs_" . $time . ".zip", ZipArchive::CREATE);

$num = 0;
while($row = mysql_fetch_array($result)) {
    /* associate a random # assigned to each PDF file name */
    $num++;
        include($form);
    $rand = rand(1,50000);
     $file_num = $num * $rand;
    $fo = fopen('c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.html', 'w') or die("can't open file");
    fwrite($fo, $output);
    echo shell_exec('c:'wkhtmltopdf'wkhtmltoimage c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.html c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg');
    /* the follow uses ghost script to execute the ImageMagick convert command from cmd.exe */
    $magick_dir = 'C:'imagemagick'; // install IM in short DOS 8.3 compatible path
    $send_cmd=$magick_dir .''convert c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg -resize "1710x2200^!" c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg' ;
    echo shell_exec($send_cmd);
    $send_cmd=$magick_dir .''convert c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.pdf';
    echo shell_exec($send_cmd);
    /* EO ghostscript code */
/* add the newly generated files to the Zip Archive */
    if ($res === TRUE) {
    //echo "RESULT TRUE...";
     $zip->addFile('c:/pdfgenerator/f-' . $time . '/mf_pdf-' . $time . '-' . $file_num . '.pdf','c:/pdfgenerator/f-' . $time . '/mf_pdf-' . $time . '-' . $file_num . '.pdf');
    //echo "FILE ADDED!";
    } 
}
echo "<h2><a href='"http://50.63.85.232/med/pdf/tmppdf/mf-pdfs_$time.zip'">Download Zip</a></h2>";
echo "<h2><a href='"index.php'">Start Over</a></h2>";
$zip->close("pdf/tmppdf/mf-pdfs_" . $time . ".zip", ZipArchive::close());
}

}

特定壳体系列

echo shell_exec('c:'wkhtmltopdf'wkhtmltoimage c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.html c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg');
    /* the follow uses ghost script to execute the ImageMagick convert command from cmd.exe */
    $magick_dir = 'C:'imagemagick'; // install IM in short DOS 8.3 compatible path
    $send_cmd=$magick_dir .''convert c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg -resize "1710x2200^!" c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg' ;
    echo shell_exec($send_cmd);
    $send_cmd=$magick_dir .''convert c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.jpeg c:''pdfgenerator''f-' . $time . '''mf_pdf-' . $time . '-' . $file_num . '.pdf';
    echo shell_exec($send_cmd);
转换了

我所有的mysql_函数,这些函数现在从PHP 5.5开始被弃用,并使用了MySQLi函数。