...
|
...
|
@@ -10,10 +10,10 @@ class SyncEmailMy{ |
|
|
public static function sync(){
|
|
|
while (1){
|
|
|
|
|
|
if(self::$maxGo >= 50){
|
|
|
co::sleep(1);
|
|
|
continue;
|
|
|
}
|
|
|
// if(self::$maxGo >= 50){
|
|
|
// co::sleep(1);
|
|
|
// continue;
|
|
|
// }
|
|
|
|
|
|
$id = redis()->lPop('sync_email_lists_my');
|
|
|
// _echo('读取到'.$id);
|
...
|
...
|
@@ -24,17 +24,17 @@ class SyncEmailMy{ |
|
|
self::go($id);
|
|
|
|
|
|
}
|
|
|
co::sleep(0.2);
|
|
|
// co::sleep(0.2);
|
|
|
}else{
|
|
|
co::sleep(1);
|
|
|
sleep(1);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static function go($id){
|
|
|
go(function ($id){
|
|
|
self::$maxGo++;
|
|
|
// go(function ($id){
|
|
|
// self::$maxGo++;
|
|
|
try{
|
|
|
// 开始同步
|
|
|
(new \Service\SyncMail($id))->isUidAfter(2)->sync();
|
...
|
...
|
@@ -42,16 +42,16 @@ class SyncEmailMy{ |
|
|
_echo($e->getMessage());
|
|
|
}
|
|
|
|
|
|
co::defer(function () use ($id){
|
|
|
self::$maxGo--;
|
|
|
// co::defer(function () use ($id){
|
|
|
// self::$maxGo--;
|
|
|
// 30秒后 消除占用
|
|
|
redis()->expire('just_sync_'.$id,30);
|
|
|
|
|
|
\Lib\Log::getInstance()->write();
|
|
|
|
|
|
db()->close();
|
|
|
});
|
|
|
},$id);
|
|
|
// db()->close();
|
|
|
// });
|
|
|
// },$id);
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -61,7 +61,7 @@ class SyncEmailMy{ |
|
|
$pm = new \Swoole\Process\Manager();
|
|
|
|
|
|
// 启动业务进程
|
|
|
$pm->addBatch(2,function (\Swoole\Process\Pool $pool, int $worker_id){
|
|
|
$pm->addBatch(100,function (\Swoole\Process\Pool $pool, int $worker_id){
|
|
|
//error_reporting();
|
|
|
include_once __DIR__."/../vendor/autoload.php";
|
|
|
|
...
|
...
|
@@ -71,7 +71,7 @@ $pm->addBatch(2,function (\Swoole\Process\Pool $pool, int $worker_id){ |
|
|
|
|
|
SyncEmailMy::sync();
|
|
|
|
|
|
},true);
|
|
|
},false);
|
|
|
|
|
|
$pm->start();
|
|
|
|
...
|
...
|
|