|
|
#!/alidata/server/php/bin/php
|
|
|
<?php
|
|
|
@ini_set('display_errors', '1');
|
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
|
|
|
|
|
$rootDir = dirname(dirname(__FILE__));
|
|
|
include $rootDir . '/zc-framework/zc.php';
|
|
|
|
|
|
Zc::import('zc.vendors.YwCurl');
|
|
|
$ywCurl = new YwCurl(array (
|
|
|
'useCookie' => false,
|
|
|
'timeOut' => 7200
|
|
|
));
|
|
|
|
|
|
function echoInfo($content) {
|
|
|
$content = date('Y-m-d H:i:s') . " $content\r\n";
|
|
|
echo $content;
|
|
|
}
|
|
|
|
|
|
$timerCode = $argv[1];
|
|
|
$appName = $argv[4];
|
|
|
$isLive = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (stripos(__FILE__, '/alidata/www/') !== false);
|
|
|
$host = $isLive ? 'pdd.chengji-inc.com' : 'pdd.chengji-inc.me';
|
|
|
if ($appName == 'pdd-od') {
|
|
|
$host = $isLive ? 'pdd-od.chengji-inc.com' : 'pdd-od.chengji-inc.me';
|
|
|
}
|
|
|
if ($appName == 'pdd-sp') {
|
|
|
$host = $isLive ? 'pdd-sp.chengji-inc.com' : 'pdd-sp.chengji-inc.me';
|
|
|
}
|
|
|
if ($appName == 'pdddz') {
|
|
|
$host = $isLive ? 'pdddz.jiancent.com' : 'pdddz.jiancent.me';
|
|
|
}
|
|
|
if ($appName == 'pdddz-sh') {
|
|
|
$host = $isLive ? 'sh.pdddz.jiancent.com' : 'sh.pdddz.jiancent.me';
|
|
|
}
|
|
|
if ($appName == 'pdddz-od') {
|
|
|
$host = $isLive ? 'pdddz-od.jiancent.com' : 'pdddz-od.jiancent.me';
|
|
|
}
|
|
|
if ($appName == 'pdddz-sp') {
|
|
|
$host = $isLive ? 'pdddz-sp.jiancent.com' : 'pdddz-sp.jiancent.me';
|
|
|
}
|
|
|
if ($appName == 'agate') {
|
|
|
$host = $isLive ? 'agate-pdd.ry-inc.com' : 'agate-pdd.ry-inc.com';
|
|
|
}
|
|
|
|
|
|
$url = sprintf('http://%s/%s', $host, $timerCode);
|
|
|
|
|
|
$waitSleepSecond = $argv[2];
|
|
|
$nextSleepSecond = $argv[3];
|
|
|
|
|
|
echoInfo("start {$timerCode}, and the timer url[{$url}] waitSleepSecond[{$waitSleepSecond}] nextSleepSecond[{$nextSleepSecond}]");
|
|
|
|
|
|
// 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($waitSleepSecond * 1000000);
|
|
|
$ret = $ywCurl->get($nextUrl);
|
|
|
break;
|
|
|
case 'next':
|
|
|
usleep($nextSleepSecond * 1000000);
|
|
|
$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!!"); |