...
|
...
|
@@ -4,28 +4,16 @@ |
|
|
|
|
|
use Swoole\Process;
|
|
|
|
|
|
include_once __DIR__."/../vendor/autoload.php";
|
|
|
|
|
|
|
|
|
function start(){
|
|
|
|
|
|
// 删除停止运行的值
|
|
|
// redis()->delete(SYNC_RUNNING_REDIS_KEY,'email_sync_stop_num');
|
|
|
|
|
|
// 进程管理器
|
|
|
$pm = new Process\Manager();
|
|
|
|
|
|
// 启动业务进程
|
|
|
$pm->addBatch(10,function (Process\Pool $pool, int $worker_id){
|
|
|
|
|
|
swoole_set_process_name('php-email-sync-list-'.$worker_id);
|
|
|
|
|
|
include_once __DIR__."/../vendor/autoload.php";
|
|
|
_echo("业务进程({$worker_id})启动成功");
|
|
|
|
|
|
\Co\run(function (){
|
|
|
$goNum = 0;
|
|
|
// 循环阻塞
|
|
|
while (true){
|
|
|
|
|
|
if($goNum>=200){
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 需要同步的id
|
|
|
$id = redis()->lPop('sync_email_lists');
|
|
|
|
...
|
...
|
@@ -53,30 +41,20 @@ function start(){ |
|
|
});
|
|
|
|
|
|
});
|
|
|
while ($goNum == 0){
|
|
|
co::sleep(0.5);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}else{
|
|
|
co::sleep(1);
|
|
|
break;
|
|
|
}
|
|
|
//每次都暂停1秒,防止同一时间启动太多的任务
|
|
|
co::sleep(0.5);
|
|
|
}
|
|
|
|
|
|
},true);
|
|
|
|
|
|
|
|
|
// 启动管理器
|
|
|
$pm->start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
while ($goNum == 0){
|
|
|
co::sleep(0.5);
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|