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