正在显示
1 个修改的文件
包含
16 行增加
和
10 行删除
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | 10 | ||
| 11 | use App\Http\Controllers\Api\NoticeController; | 11 | use App\Http\Controllers\Api\NoticeController; |
| 12 | use Illuminate\Console\Command; | 12 | use Illuminate\Console\Command; |
| 13 | -use Illuminate\Support\Facades\Log; | ||
| 14 | use Illuminate\Support\Facades\Redis; | 13 | use Illuminate\Support\Facades\Redis; |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -32,31 +31,38 @@ class DownloadFile extends Command | @@ -32,31 +31,38 @@ class DownloadFile extends Command | ||
| 32 | public function handle() | 31 | public function handle() |
| 33 | { | 32 | { |
| 34 | while (true) { | 33 | while (true) { |
| 34 | + $info = Redis::rpop(env('REDIS_NAME', 'handle_html')); | ||
| 35 | + if (empty($info)) { | ||
| 36 | + sleep(60); | ||
| 37 | + return true; | ||
| 38 | + } | ||
| 35 | try { | 39 | try { |
| 36 | - $this->websiteHandle(); | ||
| 37 | - sleep(30); | 40 | + $infoArr = json_decode($info, true); |
| 41 | + $this->websiteHandle($infoArr); | ||
| 42 | + sleep(2); | ||
| 38 | } catch (\Exception $e) { | 43 | } catch (\Exception $e) { |
| 39 | - sleep(30); | 44 | + Redis::lpush(env('REDIS_NAME', 'handle_html'), $info); |
| 45 | + sleep(180); | ||
| 40 | } | 46 | } |
| 47 | + | ||
| 48 | + return true; | ||
| 41 | } | 49 | } |
| 50 | + | ||
| 42 | return true; | 51 | return true; |
| 43 | } | 52 | } |
| 44 | 53 | ||
| 45 | /** | 54 | /** |
| 46 | * 处理HTML | 55 | * 处理HTML |
| 47 | */ | 56 | */ |
| 48 | - public function websiteHandle() | 57 | + public function websiteHandle($infoArr) |
| 49 | { | 58 | { |
| 50 | - $info = Redis::rpop(env('REDIS_NAME','handle_html')); | ||
| 51 | - if (!empty($info)) { | ||
| 52 | $this->output('网站更新开始'); | 59 | $this->output('网站更新开始'); |
| 60 | + | ||
| 53 | $noticeController = new NoticeController(); | 61 | $noticeController = new NoticeController(); |
| 54 | - $infoArr = json_decode($info, true); | ||
| 55 | $noticeController->websiteHtmlHandle($infoArr["zip_count"], $infoArr["domain"]); | 62 | $noticeController->websiteHtmlHandle($infoArr["zip_count"], $infoArr["domain"]); |
| 63 | + | ||
| 56 | $this->output('网站更新结束'); | 64 | $this->output('网站更新结束'); |
| 57 | } | 65 | } |
| 58 | - return true; | ||
| 59 | - } | ||
| 60 | 66 | ||
| 61 | /** | 67 | /** |
| 62 | * 输出处理日志 | 68 | * 输出处理日志 |
-
请 注册 或 登录 后发表评论