#!/alidata/server/php/bin/php false, 'timeOut' => 7200 )); function echoInfo($content) { $content = date('Y-m-d H:i:s') . " $content\r\n"; echo $content; } $timerCode = 'timer/move_goods_add/process_goods_add'; $host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'pdd.szchengji-inc.com'; $url = sprintf('http://%s/%s', $host, $timerCode); echoInfo("start {$timerCode}, and the init url[{$url}]"); // curl获取远程数据 $ret = $ywCurl->get($url); while (!empty($ret)) { // 解析返回结果,并构造下个shell 脚本 $data = json_decode($ret, true); $action = $data['action']; $nextUrl = $data['nextUrl']; echoInfo("action is [{$action}], next page {$timerCode}, the url [{$nextUrl}]"); switch ($action) { case 'wait': usleep(mt_rand(2000000, 4000000)); $ret = $ywCurl->get($nextUrl); break; case 'next': usleep(500000); $ret = $ywCurl->get($nextUrl); break; case 'end': echoInfo('action is end, set ret null, bye!'); $ret = null; break; default: echoInfo('action is unknow, maybe something error, set ret null, bye!'); $ret = null; break; } } echoInfo("end {$timerCode}, bye!!");