...
|
...
|
@@ -27,10 +27,9 @@ class SyncToEsCmd { |
|
|
// pcntl_signal(SIGHUP, $handler);
|
|
|
|
|
|
|
|
|
$es = (new Lib\Es\Es('hg_ai_emails'));
|
|
|
$es = es();
|
|
|
$db = db();
|
|
|
|
|
|
|
|
|
while (1){
|
|
|
|
|
|
// 检查是否接收到信号
|
...
|
...
|
@@ -42,25 +41,25 @@ class SyncToEsCmd { |
|
|
}
|
|
|
|
|
|
$id = redis()->lPop('sync_to_es');
|
|
|
$code = 500;
|
|
|
if($id){
|
|
|
$data = $db->throw()->first(\Model\listsSql::first('`id` = '.$id));
|
|
|
$data = $db->first(\Model\listsSql::first('`id` = '.$id));
|
|
|
if($data){
|
|
|
// 设置 进程 是否在运行
|
|
|
$data['is_auto']=$db->throw()->count('select count(*) from `lists_auto` where `list_id` = '.$data['id']) ? 1 : 0;
|
|
|
$data['is_auto']=$db->count('select count(*) from `lists_auto` where `list_id` = '.$data['id']) ? 1 : 0;
|
|
|
|
|
|
$data = $this->getEsData($data);
|
|
|
$doc_id = $data['email_id'].'_'.$data['folder_id'].'_'.$data['uid'];
|
|
|
|
|
|
$code = $es->save($doc_id,$data);
|
|
|
if($code!==200){
|
|
|
@file_put_contents(LOG_PATH.'/sync_es_fail.log',$id."\n",FILE_APPEND);
|
|
|
redis()->rPush('sync_to_es',$id);
|
|
|
_echo('同步es: '.$doc_id.'===>'.$code);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if($code!==200){
|
|
|
@file_put_contents(LOG_PATH.'/sync_es_fail.log',$id."\n",FILE_APPEND);
|
|
|
_echo('同步es: '.$doc_id.'===>'.$code);
|
|
|
}
|
|
|
|
|
|
sleep(1);
|
|
|
}
|
|
|
|
...
|
...
|
|