正在显示
1 个修改的文件
包含
31 行增加
和
1 行删除
| @@ -100,8 +100,38 @@ class SyncToEsCmd { | @@ -100,8 +100,38 @@ class SyncToEsCmd { | ||
| 100 | protected $bulkData; | 100 | protected $bulkData; |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | + public function checkfile(){ | ||
| 104 | + | ||
| 105 | + if(redis()->add('sync_es_fail_load_lock',1,10)){ | ||
| 106 | + $body = file_get_contents(LOG_PATH."/sync_es_fail.log"); | ||
| 107 | + if($body){ | ||
| 108 | + // 备份文件 | ||
| 109 | + if(file_put_contents(LOG_PATH."/sync_es_fail.".date('Y-m-d H:i:s').".log",$body)){ | ||
| 110 | + | ||
| 111 | + file_put_contents(LOG_PATH."/sync_es_fail.log",''); | ||
| 112 | + $body = explode("\n",$body); | ||
| 113 | + echo count($body)." 个\n"; | ||
| 114 | + // 清空当前文件 | ||
| 115 | + | ||
| 116 | + foreach ($body as $i=>$id){ | ||
| 117 | + if($id) redis()->rPush('sync_to_es', trim($id)); | ||
| 118 | + } | ||
| 119 | + echo 'end'; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + | ||
| 103 | public function handler(){ | 129 | public function handler(){ |
| 104 | 130 | ||
| 131 | + $this->checkfile(); | ||
| 132 | + | ||
| 133 | + sleep(5); | ||
| 134 | + | ||
| 105 | $this->es = es('email_lists_copy'); // 第二个库 新 | 135 | $this->es = es('email_lists_copy'); // 第二个库 新 |
| 106 | 136 | ||
| 107 | $this->bulkData = new \Lib\Es\BulkData(); | 137 | $this->bulkData = new \Lib\Es\BulkData(); |
| @@ -267,7 +297,7 @@ class SyncToEsCmd { | @@ -267,7 +297,7 @@ class SyncToEsCmd { | ||
| 267 | public function setEsMap($index){ | 297 | public function setEsMap($index){ |
| 268 | $this->es->setIndex($index); | 298 | $this->es->setIndex($index); |
| 269 | if($this->es->getMapping()){ | 299 | if($this->es->getMapping()){ |
| 270 | - return 9; | 300 | + return 9; |
| 271 | } | 301 | } |
| 272 | 302 | ||
| 273 | if(redis()->add('setmaplock:'.$index,1,20)){ | 303 | if(redis()->add('setmaplock:'.$index,1,20)){ |
-
请 注册 或 登录 后发表评论