...
|
...
|
@@ -17,9 +17,12 @@ function start(){ |
|
|
break;
|
|
|
}
|
|
|
|
|
|
$lists = db()->all(\Model\sendJobsSql::sendList());
|
|
|
$lists = db()->all(\Model\sendJobsSql::sendList(500-$cNum));
|
|
|
// 循环
|
|
|
foreach ($lists as $list){
|
|
|
|
|
|
// 占用 id
|
|
|
if(redis()->add('send_job_run_id_'.$list['id'],$list['id'])){
|
|
|
go(function ($data) use (&$cNum){
|
|
|
$cNum++; // 协程数+1
|
|
|
// 表单数据
|
...
|
...
|
@@ -87,15 +90,20 @@ function start(){ |
|
|
}
|
|
|
|
|
|
// 协程结束后
|
|
|
co::defer(function () use(&$cNum){
|
|
|
co::defer(function ($id) use(&$cNum,$data){
|
|
|
$cNum--;
|
|
|
// 结束后要关闭数据库链接,不然链接一直暂用
|
|
|
db()->close();
|
|
|
// 删除占用
|
|
|
redis()->delete('send_job_run_id_'.$data['id']);
|
|
|
redis()->close();
|
|
|
});
|
|
|
|
|
|
},$list);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch (Throwable $e){
|
|
|
logs($e->getMessage().$e->getTraceAsString());
|
|
|
}
|
...
|
...
|
|