php-fpm:fastcgi_finish_request()

來源:互聯網
上載者:User

標籤: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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.