Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions inc/cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down