|
@@ -1128,7 +1128,6 @@ class TestLog extends PHPUnit_Framework_TestCase
|
|
|
$info = pathinfo($url);
|
|
|
|
|
|
if(!file_exists($path)) {
|
|
|
-// $pic_url = $info['dirname'] . '/' . urlencode($info['basename']);
|
|
|
$pic_url = $info['dirname'] . '/' . str_replace(' ','%20',$info['basename']);
|
|
|
exec("wget -O $path $pic_url");
|
|
|
}
|
|
@@ -1145,6 +1144,61 @@ class TestLog extends PHPUnit_Framework_TestCase
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+ public function testMonitor()
|
|
|
+ {
|
|
|
+ $fd = @fopen(BASE_ROOT_PATH . "/data/log/20180831.log", "c+");
|
|
|
+ $stdout = fopen('php://stdout', 'w');
|
|
|
+
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ $line = fread($fd,1024);
|
|
|
+ if ($line !== false && !empty($line)) {
|
|
|
+ fwrite($stdout,$line);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ fwrite($stdout,"fread empty line\n");
|
|
|
+ usleep(1000000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testMonitorSelect()
|
|
|
+ {
|
|
|
+ $fd = @fopen(BASE_ROOT_PATH . "/data/log/20180831.log", "c+");
|
|
|
+ $stdout = fopen('php://stdout', 'w');
|
|
|
+
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ $wfds = null;
|
|
|
+ $xfds = null;
|
|
|
+ $rfds = [$fd];
|
|
|
+
|
|
|
+ $timeout = 2;
|
|
|
+ $number = stream_select($rfds, $wfds, $xfds, $timeout, 0);
|
|
|
+ if($number > 0)
|
|
|
+ {
|
|
|
+ if(!empty($rfds))
|
|
|
+ {
|
|
|
+ $line = fread($fd,1024);
|
|
|
+ if ($line !== false && !empty($line)) {
|
|
|
+ fwrite($stdout,$line);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ fwrite($stdout,"fread empty line\n");
|
|
|
+ usleep(1000000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ fwrite($stdout,"no content to read\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ fwrite($stdout,"ret = {$number}\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ fwrite($stdout,"ret = {$number}\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function testStat()
|
|
|
{
|