diff --git a/inc/cluster.php b/inc/cluster.php index 3ca86c8..db76cfb 100644 --- a/inc/cluster.php +++ b/inc/cluster.php @@ -135,7 +135,7 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) { mlog("Error connecting to the main control:{$client->errMsg}",2); return false; } - elseif($client->statusCode == "200"){ + elseif($client->statusCode == 200){ $bar->progress(); return true; } @@ -173,7 +173,7 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) { } if (!$downloader) { echo PHP_EOL; - mlog("{$file->path} Download Failed: {$client->errMsg} From Node: {$location_url['host']}:{$location_url['port']}",2); + mlog("{$file->path} Download Failed: {$client->errMsg} | {$location_url['host']}:{$location_url['port']}",2); $bar->progress(); return false; } @@ -186,7 +186,13 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) { else{ if (!$downloader) { echo PHP_EOL; - mlog("{$file->path} Download Failed: {$client->errMsg} From Node: {$location_url['host']}:{$location_url['port']}",2); + mlog("{$file->path} Download Failed: {$client->errMsg} | {$location_url['host']}:{$location_url['port']}",2); + $bar->progress(); + return false; + } + elseif($client->statusCode >= 400){ + echo PHP_EOL; + mlog("Download Failed:{$client->statusCode} | {$file->path} | {$location_url['host']}:{$location_url['port']}",2); $bar->progress(); return false; } diff --git a/main.php b/main.php index 6772fb2..79a873d 100644 --- a/main.php +++ b/main.php @@ -22,13 +22,13 @@ run(function()use ($config){ //注册信号处理器 function registerSigintHandler() { - global $tokentimeid; + global $tokentimerid; $shouldExit = false; // 初始化为false - Swoole\Process::signal(SIGINT, function ($signo) use ($tokentimeid) { + Swoole\Process::signal(SIGINT, function ($signo) use ($tokentimerid) { try { global $shouldExit; $shouldExit = true; // 设置退出标志 - Swoole\Timer::clear($tokentimeid); + Swoole\Timer::clear($tokentimerid); echo PHP_EOL; mlog("正在退出..."); exit(); @@ -45,13 +45,13 @@ function registerSigintHandler() { mlog("GetToken:".$tokendata['token'],1); mlog("TokenTTL:".$tokendata['upttl'],1); //启动更新TokenTimer - global $tokentimeid; - $tokentimeid = Swoole\Timer::tick($tokendata['upttl'], function () use ($token) { + global $tokentimerid; + $tokentimerid = Swoole\Timer::tick($tokendata['upttl'], function () use ($token) { $tokendata = $token->gettoken(); mlog("GetNewToken:".$tokendata['token'],1); }); registerSigintHandler(); - mlog("Timer start on ID{$tokentimeid}",1); + mlog("Timer start on ID{$tokentimerid}",1); //下载文件列表 $cluster = new cluster($tokendata['token'],VERSION);