BaseCommands.php
870 字节
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
<?php
namespace App\Console\Commands\RankData;
use Illuminate\Console\Command;
/**
* Class BaseCommands
* @package App\Console\Commands\RankData
* @author zbj
* @date 2023/5/11
*/
abstract class BaseCommands extends Command
{
/**
* @author zbj
* @date 2023/5/11
*/
public function handle()
{
$try = 3;
do{
$try--;
if($try == 0){
break;
}
$error = 0;
try {
if(!$this->do()){
$error = 1;
}
}catch (\Exception $e){
errorLog($this->signature . ' error', [], $e);
$error = 1;
}
if($error){
echo 'error';
}
$error && sleep(10);
}while($error);
}
abstract function do();
}