...
|
...
|
@@ -26,14 +26,40 @@ class SyncToEsCmd { |
|
|
*/
|
|
|
public $fob_db;
|
|
|
|
|
|
/**
|
|
|
* @var \Lib\Db
|
|
|
*/
|
|
|
public $db;
|
|
|
|
|
|
|
|
|
public $startTime = 0;
|
|
|
|
|
|
/**
|
|
|
* SyncToEsCmd constructor.
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->db = db();
|
|
|
$this->fob_db = fob_mysql();
|
|
|
|
|
|
$handler = function ($signal){
|
|
|
_echo('收到进程信号 '. $signal);
|
|
|
// 可以处理其他程序
|
|
|
$this->isStop = true;
|
|
|
};
|
|
|
pcntl_signal(SIGTERM, $handler); // 这个是kill
|
|
|
pcntl_signal(SIGINT, $handler); // 这个是 ctrl+c
|
|
|
|
|
|
$this->startTime = time();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否是自动回复
|
|
|
* @author:dc
|
|
|
* @time 2025/6/6 11:07
|
|
|
*/
|
|
|
public function isAuto($db,$data){
|
|
|
$is_auto = $db ->count('select count(*) from `lists_auto` where `list_id` = '.$data['id']) ? 1 : 0;
|
|
|
public function isAuto($data){
|
|
|
$is_auto = $this->db->count('select count(*) from `lists_auto` where `list_id` = '.$data['id']) ? 1 : 0;
|
|
|
|
|
|
if($is_auto) return 1;
|
|
|
|
...
|
...
|
@@ -54,43 +80,36 @@ class SyncToEsCmd { |
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
public function handler(){
|
|
|
/**
|
|
|
* @return bool
|
|
|
*/
|
|
|
public function isStop(): bool
|
|
|
{
|
|
|
// 检查是否接收到信号
|
|
|
pcntl_signal_dispatch();
|
|
|
|
|
|
$handler = function ($signal){
|
|
|
_echo('收到进程信号 '. $signal);
|
|
|
// 可以处理其他程序
|
|
|
$this->isStop = true;
|
|
|
};
|
|
|
pcntl_signal(SIGTERM, $handler); // 这个是kill
|
|
|
pcntl_signal(SIGINT, $handler); // 这个是 ctrl+c
|
|
|
// pcntl_signal(SIGHUP, $handler);
|
|
|
// 是否超过来最大执行时间
|
|
|
if(time()-43200 > $this->startTime){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$es = es(); // 第一个库,即将丢弃
|
|
|
$es2 = es('email_lists'); // 第二个库 新
|
|
|
return $this->isStop;
|
|
|
}
|
|
|
|
|
|
$db = db();
|
|
|
$this->fob_db = fob_mysql();
|
|
|
$startTime = time();
|
|
|
while (1){
|
|
|
|
|
|
if(time()-43200 > $startTime){
|
|
|
break;
|
|
|
}
|
|
|
public function handler(){
|
|
|
|
|
|
// 检查是否接收到信号
|
|
|
pcntl_signal_dispatch();
|
|
|
$es = es(); // 第一个库,即将丢弃
|
|
|
$es2 = es('email_lists'); // 第二个库 新
|
|
|
|
|
|
if($this->isStop) {
|
|
|
_echo('已退出进程');
|
|
|
break;
|
|
|
}
|
|
|
while (!$this->isStop()){
|
|
|
|
|
|
$id = redis()->lPop('sync_to_es');
|
|
|
$code = 500;
|
|
|
if($id){
|
|
|
$doc_id = '';
|
|
|
try {
|
|
|
$data = $db->throw()->first(\Model\listsSql::first('`id` = '.$id));
|
|
|
$data = $this->db->throw()->first(\Model\listsSql::first('`id` = '.$id));
|
|
|
}catch (Throwable $e){
|
|
|
redis()->rPush('sync_to_es',$id);
|
|
|
_echo('sync to es '.$e->getMessage());
|
...
|
...
|
@@ -101,7 +120,7 @@ class SyncToEsCmd { |
|
|
try {
|
|
|
// 文件夹
|
|
|
if(empty($this->folders[$data['folder_id']])){
|
|
|
$this->folders[$data['folder_id']] = $db->throw()->value(\Model\folderSql::first($data['folder_id'],'folder'));
|
|
|
$this->folders[$data['folder_id']] = $this->db->throw()->value(\Model\folderSql::first($data['folder_id'],'folder'));
|
|
|
}
|
|
|
|
|
|
// 为文件夹打标 方便查询
|
...
|
...
|
@@ -109,7 +128,7 @@ class SyncToEsCmd { |
|
|
|
|
|
// 是否是自动回复
|
|
|
if($data['folder_as_int'] === 1){
|
|
|
$data['is_auto'] = $this->isAuto($db,$data);
|
|
|
$data['is_auto'] = $this->isAuto($data);
|
|
|
}
|
|
|
|
|
|
// postid ai邮箱要用 这个是查询黑格
|
...
|
...
|
@@ -144,7 +163,6 @@ class SyncToEsCmd { |
|
|
|
|
|
}
|
|
|
|
|
|
protected $postids = [];
|
|
|
|
|
|
/**
|
|
|
* 项目id
|
...
|
...
|
|