UpdateProgress.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @remark :
* @name :UpdateProgress.php
* @author :lyh
* @method :post
* @time :2023/11/1 9:22
*/
namespace App\Console\Commands;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Models\Com\UpdateProgress as UpdateProgressModel;
class UpdateProgress extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_progress';
/**
* The console command description.
*
* @var string
*/
protected $description = '守护进程--更新界面';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
while (true){
$project_id = Redis::rpop('updateSeoTdk');
if(!$project_id){
sleep(2);
continue;
}
echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
}
}
/**
* @remark :查看是否有为更新的记录
* @name :updateProgress
* @author :lyh
* @method :post
* @time :2023/11/1 10:47
*/
public function getUpdateProgress(){
$list = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->get();
if(!empty($list)){
$list = $list->toArray();
}
}
}