作者 邓超

x

... ... @@ -41,6 +41,7 @@ class HotMail {
private function start(){
_echo('启动预热邮件处理 '.getmypid());
if(redis()->add('hot_mail_sync',1)){
$fob = $this->getFobHotEmail();
// 把黑格自己的也算进去
... ... @@ -61,7 +62,6 @@ class HotMail {
}catch (Throwable $e){}
}
$maxId = $this->db->value("select `id` from `lists` order by `id` desc limit 1");
$id = 0;
while (1){
... ... @@ -71,12 +71,30 @@ class HotMail {
}
$id = end($ids);
$this->run($ids);
redis()->rPush('hot_check_ids',implode(',',$ids));
if($id>$maxId){
break;
}
}
redis()->set('hot_mail_sync',1,60);
}
while (1){
$ids = redis()->lPop('hot_check_ids');
if($ids){
$ids = explode(',',$ids);
$this->run($ids);
}else{
echo '等待'.PHP_EOL;
co::sleep(2);
}
}
echo '已执行完成'.PHP_EOL;
}
... ... @@ -98,7 +116,7 @@ class HotMail {
$w = ['email' =>$item['from']];
}
// 是否在 预热邮箱中
if($this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
if($this->db->cache(300)->count('select count(*) from `hot_mail` where '.dbWhere($w))){
$ret = $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$item['id']]));
echo date('d H:i:s').' ==》 '.$item['id'].':'.$ret."\n";
... ... @@ -156,7 +174,7 @@ swoole_set_process_name('hot-email-run-man');
$pm = new Swoole\Process\Manager();
$pm->add(function (){
$pm->addBatch(10,function (){
swoole_set_process_name('hot-email-run');
... ... @@ -165,7 +183,7 @@ $pm->add(function (){
new HotMail();
// 执行完了暂停5分钟在执行
sleep(300);
});
},true);
$pm->start();
... ...