码迷,mamicode.com
首页 > Web开发 > 详细

php-fpm:fastcgi_finish_request()

时间:2014-08-14 13:51:48      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   strong   for   ar   

    开始研究php-fpm, 在php-fpm的官网上发现一些很有用的功能,记录一下


1、支持php脚本执行慢的log记录

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the ‘slowlog‘ file. A value of ‘0s‘ means ‘off‘.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

 

2、提供一些非常有用的函数,特别是

fastcgi_finish_request() //    a special function to finish request & flush all data while continuing to do something time-consuming (video converting, stats processing, etc.)

关于该函数,火丁笔记做了记录和实验,鸟哥做了转载和补充,这里整理一下

 1 <?php
 2 
 3 //代码的可移植性讲的话, 可以在代码中附上如下代码:
 4 if (!function_exists("fastcgi_finish_request")) {
 5     function fastcgi_finish_request() {
 6     }
 7 }
 8 
 9 echo ‘例子:‘;     
10 file_put_contents(‘log.txt‘, date(‘Y-m-d H:i:s‘) . " 上传视频\n", FILE_APPEND);  
11 
12 //结束和客户端的交互,将结果刷出   
13 fastcgi_finish_request();  
14 
15 //服务端继续执行代码     
16 sleep(1);
17 file_put_contents(‘log.txt‘, date(‘Y-m-d H:i:s‘) . " 转换格式\n", FILE_APPEND);
18      
19 sleep(1);
20 file_put_contents(‘log.txt‘, date(‘Y-m-d H:i:s‘) . " 提取图片\n", FILE_APPEND);

 

参考:
php-fpm网站   http://php-fpm.org/
火丁笔记         http://huoding.com/2011/04/12/63
鸟哥              http://www.laruence.com/2011/04/13/1991.html

 

php-fpm:fastcgi_finish_request(),布布扣,bubuko.com

php-fpm:fastcgi_finish_request()

标签:style   blog   http   color   io   strong   for   ar   

原文地址:http://www.cnblogs.com/yimuren/p/3912073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!