即使max_execution_time& amp; IIS7连接超时已设置

时间:2013-01-25 06:27:19

标签: php iis-7 connection timeout

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

项目背景我的脚本通过“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.ini http://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);

1 个答案:

答案 0 :(得分:0)

转换了我的所有 mysql_ functions ,现在已经弃用了PHP 5.5,并使用了MySQLi个函数。

相关问题