作者 邓超

proxy

@@ -10,10 +10,10 @@ class SyncEmailMy{ @@ -10,10 +10,10 @@ class SyncEmailMy{
10 public static function sync(){ 10 public static function sync(){
11 while (1){ 11 while (1){
12 12
13 - if(self::$maxGo >= 50){  
14 - co::sleep(1);  
15 - continue;  
16 - } 13 +// if(self::$maxGo >= 50){
  14 +// co::sleep(1);
  15 +// continue;
  16 +// }
17 17
18 $id = redis()->lPop('sync_email_lists_my'); 18 $id = redis()->lPop('sync_email_lists_my');
19 // _echo('读取到'.$id); 19 // _echo('读取到'.$id);
@@ -24,17 +24,17 @@ class SyncEmailMy{ @@ -24,17 +24,17 @@ class SyncEmailMy{
24 self::go($id); 24 self::go($id);
25 25
26 } 26 }
27 - co::sleep(0.2); 27 +// co::sleep(0.2);
28 }else{ 28 }else{
29 - co::sleep(1); 29 + sleep(1);
30 } 30 }
31 31
32 } 32 }
33 } 33 }
34 34
35 public static function go($id){ 35 public static function go($id){
36 - go(function ($id){  
37 - self::$maxGo++; 36 +// go(function ($id){
  37 +// self::$maxGo++;
38 try{ 38 try{
39 // 开始同步 39 // 开始同步
40 (new \Service\SyncMail($id))->isUidAfter(2)->sync(); 40 (new \Service\SyncMail($id))->isUidAfter(2)->sync();
@@ -42,16 +42,16 @@ class SyncEmailMy{ @@ -42,16 +42,16 @@ class SyncEmailMy{
42 _echo($e->getMessage()); 42 _echo($e->getMessage());
43 } 43 }
44 44
45 - co::defer(function () use ($id){  
46 - self::$maxGo--; 45 +// co::defer(function () use ($id){
  46 +// self::$maxGo--;
47 // 30秒后 消除占用 47 // 30秒后 消除占用
48 redis()->expire('just_sync_'.$id,30); 48 redis()->expire('just_sync_'.$id,30);
49 49
50 \Lib\Log::getInstance()->write(); 50 \Lib\Log::getInstance()->write();
51 51
52 - db()->close();  
53 - });  
54 - },$id); 52 +// db()->close();
  53 +// });
  54 +// },$id);
55 } 55 }
56 56
57 } 57 }
@@ -61,7 +61,7 @@ class SyncEmailMy{ @@ -61,7 +61,7 @@ class SyncEmailMy{
61 $pm = new \Swoole\Process\Manager(); 61 $pm = new \Swoole\Process\Manager();
62 62
63 // 启动业务进程 63 // 启动业务进程
64 -$pm->addBatch(2,function (\Swoole\Process\Pool $pool, int $worker_id){ 64 +$pm->addBatch(100,function (\Swoole\Process\Pool $pool, int $worker_id){
65 //error_reporting(); 65 //error_reporting();
66 include_once __DIR__."/../vendor/autoload.php"; 66 include_once __DIR__."/../vendor/autoload.php";
67 67
@@ -71,7 +71,7 @@ $pm->addBatch(2,function (\Swoole\Process\Pool $pool, int $worker_id){ @@ -71,7 +71,7 @@ $pm->addBatch(2,function (\Swoole\Process\Pool $pool, int $worker_id){
71 71
72 SyncEmailMy::sync(); 72 SyncEmailMy::sync();
73 73
74 -},true); 74 +},false);
75 75
76 $pm->start(); 76 $pm->start();
77 77