...
|
...
|
@@ -100,8 +100,38 @@ class SyncToEsCmd { |
|
|
protected $bulkData;
|
|
|
|
|
|
|
|
|
public function checkfile(){
|
|
|
|
|
|
if(redis()->add('sync_es_fail_load_lock',1,10)){
|
|
|
$body = file_get_contents(LOG_PATH."/sync_es_fail.log");
|
|
|
if($body){
|
|
|
// 备份文件
|
|
|
if(file_put_contents(LOG_PATH."/sync_es_fail.".date('Y-m-d H:i:s').".log",$body)){
|
|
|
|
|
|
file_put_contents(LOG_PATH."/sync_es_fail.log",'');
|
|
|
$body = explode("\n",$body);
|
|
|
echo count($body)." 个\n";
|
|
|
// 清空当前文件
|
|
|
|
|
|
foreach ($body as $i=>$id){
|
|
|
if($id) redis()->rPush('sync_to_es', trim($id));
|
|
|
}
|
|
|
echo 'end';
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public function handler(){
|
|
|
|
|
|
$this->checkfile();
|
|
|
|
|
|
sleep(5);
|
|
|
|
|
|
$this->es = es('email_lists_copy'); // 第二个库 新
|
|
|
|
|
|
$this->bulkData = new \Lib\Es\BulkData();
|
...
|
...
|
@@ -267,7 +297,7 @@ class SyncToEsCmd { |
|
|
public function setEsMap($index){
|
|
|
$this->es->setIndex($index);
|
|
|
if($this->es->getMapping()){
|
|
|
return 9;
|
|
|
return 9;
|
|
|
}
|
|
|
|
|
|
if(redis()->add('setmaplock:'.$index,1,20)){
|
...
|
...
|
|