|
@@ -20,10 +20,17 @@ function start(){ |
|
@@ -20,10 +20,17 @@ function start(){ |
20
|
// 启动业务进程
|
20
|
// 启动业务进程
|
21
|
$pm->addBatch(WORKER_NUM,function (Process\Pool $pool, int $worker_id){
|
21
|
$pm->addBatch(WORKER_NUM,function (Process\Pool $pool, int $worker_id){
|
22
|
_echo("业务进程({$worker_id})启动成功");
|
22
|
_echo("业务进程({$worker_id})启动成功");
|
|
|
23
|
+ swoole_set_process_name('php-email-sync-list-'.$worker_id);
|
23
|
|
24
|
|
|
|
25
|
+ $run_timer = time();
|
24
|
// 循环阻塞
|
26
|
// 循环阻塞
|
25
|
while (true){
|
27
|
while (true){
|
26
|
- swoole_set_process_name('php-email-sync-list-'.$worker_id);
|
28
|
+
|
|
|
29
|
+ // 运行超过1天的 停止
|
|
|
30
|
+ if($run_timer < (time()-86400)){
|
|
|
31
|
+ break;
|
|
|
32
|
+ }
|
|
|
33
|
+
|
27
|
// 需要同步的id
|
34
|
// 需要同步的id
|
28
|
$id = redis()->lPop('sync_email_lists');
|
35
|
$id = redis()->lPop('sync_email_lists');
|
29
|
|
36
|
|
|
@@ -65,8 +72,13 @@ function start(){ |
|
@@ -65,8 +72,13 @@ function start(){ |
65
|
$pm->add(function (Process\Pool $pool, int $worker_id){
|
72
|
$pm->add(function (Process\Pool $pool, int $worker_id){
|
66
|
_echo("业务进程({$worker_id})启动成功,body");
|
73
|
_echo("业务进程({$worker_id})启动成功,body");
|
67
|
swoole_set_process_name('php-email-sync-body-'.$worker_id);
|
74
|
swoole_set_process_name('php-email-sync-body-'.$worker_id);
|
|
|
75
|
+ $run_timer = time();
|
68
|
// 循环阻塞
|
76
|
// 循环阻塞
|
69
|
while (true){
|
77
|
while (true){
|
|
|
78
|
+ // 运行超过1天的 停止
|
|
|
79
|
+ if($run_timer < (time()-86400)){
|
|
|
80
|
+ break;
|
|
|
81
|
+ }
|
70
|
// 需要同步的id
|
82
|
// 需要同步的id
|
71
|
$id = redis()->lPop('sync_email_body');
|
83
|
$id = redis()->lPop('sync_email_body');
|
72
|
|
84
|
|