作者 邓超

xxx

... ... @@ -10,6 +10,13 @@ class SendJob {
public $cnum = 0;
private $run_timer = 0;
public function __construct()
{
$this->run_timer = time();
}
/**
* 是否停止
* @return bool
... ... @@ -17,6 +24,10 @@ class SendJob {
* @time 2024/4/10 9:12
*/
private function isStop(){
// 运行超过1天的 停止
if($this->run_timer < (time()-86400)){
return true;
}
return redis()->get('send_job_is_stop') == 'stop';
}
... ...
... ... @@ -20,10 +20,17 @@ function start(){
// 启动业务进程
$pm->addBatch(WORKER_NUM,function (Process\Pool $pool, int $worker_id){
_echo("业务进程({$worker_id})启动成功");
swoole_set_process_name('php-email-sync-list-'.$worker_id);
$run_timer = time();
// 循环阻塞
while (true){
swoole_set_process_name('php-email-sync-list-'.$worker_id);
// 运行超过1天的 停止
if($run_timer < (time()-86400)){
break;
}
// 需要同步的id
$id = redis()->lPop('sync_email_lists');
... ... @@ -65,8 +72,13 @@ function start(){
$pm->add(function (Process\Pool $pool, int $worker_id){
_echo("业务进程({$worker_id})启动成功,body");
swoole_set_process_name('php-email-sync-body-'.$worker_id);
$run_timer = time();
// 循环阻塞
while (true){
// 运行超过1天的 停止
if($run_timer < (time()-86400)){
break;
}
// 需要同步的id
$id = redis()->lPop('sync_email_body');
... ...