最近將個 blog 由 HHVM 轉返做 PHP-FPM,因為 HHVM 真係佔幾多 ram 下(不過呢個唔係大問題)
最麻煩係 HHVM 成日會突然無反應,見佢有行緊,佔 CPU 2% - 5% 左右,但就完全唔 work,要等佢 timeout 彈返去 PHP-FPM,最有趣係過多陣就無事
唔知佢幾時會死,倒不如穩穩定定行返 PHP-FPM 算喇
「php timeout」的推薦目錄:
- 關於php timeout 在 企業號航行網誌 Facebook 的精選貼文
- 關於php timeout 在 Re: [請益] fopen http timeout的問題- 看板PHP - 批踢踢實業坊 的評價
- 關於php timeout 在 How to increase the execution timeout in php? - Stack Overflow 的評價
- 關於php timeout 在 PHP extension to control function's excution time - GitHub 的評價
- 關於php timeout 在 [转]PHP超时处理全面总结 - 风之缘 的評價
- 關於php timeout 在 How to set PHP Session Timeout (Low Code Corner #10) 的評價
- 關於php timeout 在 Php ngninx timeout - Magento Stack Exchange 的評價
php timeout 在 PHP extension to control function's excution time - GitHub 的推薦與評價
I add timeout control to it. Why written this extesion?In my work,I find many circumstances that function executed long time and block the process,so I need a ... ... <看更多>
php timeout 在 Re: [請益] fopen http timeout的問題- 看板PHP - 批踢踢實業坊 的推薦與評價
※ 引述《breazer ()》之銘言:
: 程式裡面有一行code 是長這個樣子
: $fp1 = fopen("https://192.168.0.141/xxx","r");
: 可是如果192.168.0.141 這個ip的電腦網路線被拔掉之後
: 會讓這一行code卡住 直到php本身timeout
: 結果就只執行到這一行code就停了 之後都跑不到
: 我該怎麼限制這行code的執行時間??
: 好讓這行執行太久的時候 可以跳過這行繼續執行下去
借花獻佛...https://tw.php.net/manual/en/function.fopen.php
Ex1.
If you need fopen() on a URL to timeout, you can do like:
<?php
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
$file = fopen('https://example.com', 'r');
ini_set('default_socket_timeout', $old);
stream_set_timeout($file, $timeout);
stream_set_blocking($file, 0);
//the rest is standard
?>
Ex2.
During development of a set of non-blocking functions for downloading files
from http-servers I've discovered that it's not possible to set timeout
for fopen('https://somesite.com/somefile', 'rb').
All functions for controlling non-blocking mode (stream_set_blocking,
stream_set_timeout, stream_context_set_option) use resource handle
that is created via fopen(). But fopen() for HTTP connections
internally makes quite a big set of actions: it creates socket,
resolves webserver name, establishes actual connection.
So hanging can occur anywhere in resolving and creating tcp-connection
but you cannot control it.
Solutions:
1) Use socket functions. Set socket in non-blocking mode just after creation.
Implement HTTP-protocol yourself. In source code use these manually
created functions.
2) Write a wrapper for myprotocol://, which internally will use first solution,
but in source code you'll use
fopen('myprotocol://somesite.com/somefile', 'rb') with some way
to set timeout before calling it.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.119.190.160
... <看更多>