作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !52
@@ -63,7 +63,7 @@ class HtmlCollect extends Command @@ -63,7 +63,7 @@ class HtmlCollect extends Command
63 //设置数据库 63 //设置数据库
64 $project = ProjectServer::useProject($project_id); 64 $project = ProjectServer::useProject($project_id);
65 if ($project) { 65 if ($project) {
66 - $collect_info = CollectTask::select(['id', 'domain', 'route'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->first(); 66 + $collect_info = CollectTask::select(['id', 'domain', 'route'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->where('language', '')->first();
67 67
68 if (!$collect_info) { 68 if (!$collect_info) {
69 sleep(2); 69 sleep(2);
@@ -84,6 +84,9 @@ class HtmlCollect extends Command @@ -84,6 +84,9 @@ class HtmlCollect extends Command
84 $html = $this->upload_source($html, $source_list, $project_id); 84 $html = $this->upload_source($html, $source_list, $project_id);
85 } 85 }
86 } catch (\Exception $e) { 86 } catch (\Exception $e) {
  87 + $collect_info->status = CollectTask::STATUS_FAIL;
  88 + $collect_info->save();
  89 +
87 echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $e->getMessage() . PHP_EOL; 90 echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $e->getMessage() . PHP_EOL;
88 return true; 91 return true;
89 } 92 }
@@ -137,7 +140,7 @@ class HtmlCollect extends Command @@ -137,7 +140,7 @@ class HtmlCollect extends Command
137 //设置数据库 140 //设置数据库
138 $project = ProjectServer::useProject($update_log->project_id); 141 $project = ProjectServer::useProject($update_log->project_id);
139 if ($project) { 142 if ($project) {
140 - $collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '')->where('status', CollectTask::STATUS_UN)->orderBy('language', 'asc')->limit(50)->get(); 143 + $collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '')->where('status', CollectTask::STATUS_UN)->orderBy('id', 'asc')->limit(50)->get();
141 144
142 if ($collect_list->count() == 0) { 145 if ($collect_list->count() == 0) {
143 $complete = true; 146 $complete = true;
@@ -63,7 +63,7 @@ class HtmlLanguageCollect extends Command @@ -63,7 +63,7 @@ class HtmlLanguageCollect extends Command
63 //设置数据库 63 //设置数据库
64 $project = ProjectServer::useProject($project_id); 64 $project = ProjectServer::useProject($project_id);
65 if ($project) { 65 if ($project) {
66 - $collect_info = CollectTask::select(['id', 'domain', 'route'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->first(); 66 + $collect_info = CollectTask::select(['id', 'domain', 'route'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->where('language', '!=', '')->first();
67 67
68 if (!$collect_info) { 68 if (!$collect_info) {
69 sleep(2); 69 sleep(2);
@@ -84,6 +84,9 @@ class HtmlLanguageCollect extends Command @@ -84,6 +84,9 @@ class HtmlLanguageCollect extends Command
84 $html = $this->upload_source($html, $source_list, $project_id); 84 $html = $this->upload_source($html, $source_list, $project_id);
85 } 85 }
86 } catch (\Exception $e) { 86 } catch (\Exception $e) {
  87 + $collect_info->status = CollectTask::STATUS_FAIL;
  88 + $collect_info->save();
  89 +
87 echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $e->getMessage() . PHP_EOL; 90 echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $e->getMessage() . PHP_EOL;
88 return true; 91 return true;
89 } 92 }
@@ -137,7 +140,7 @@ class HtmlLanguageCollect extends Command @@ -137,7 +140,7 @@ class HtmlLanguageCollect extends Command
137 //设置数据库 140 //设置数据库
138 $project = ProjectServer::useProject($update_log->project_id); 141 $project = ProjectServer::useProject($update_log->project_id);
139 if ($project) { 142 if ($project) {
140 - $collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '!=', '')->where('status', CollectTask::STATUS_UN)->orderBy('language', 'asc')->limit(50)->get(); 143 + $collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '!=', '')->where('status', CollectTask::STATUS_UN)->orderBy('id', 'asc')->limit(50)->get();
141 144
142 if ($collect_list->count() == 0) { 145 if ($collect_list->count() == 0) {
143 $complete = true; 146 $complete = true;
@@ -15,6 +15,7 @@ class CollectTask extends Base @@ -15,6 +15,7 @@ class CollectTask extends Base
15 const STATUS_UN = 0; 15 const STATUS_UN = 0;
16 const STATUS_ING = 1; 16 const STATUS_ING = 1;
17 const STATUS_COM = 2; 17 const STATUS_COM = 2;
  18 + const STATUS_FAIL = 3;
18 19
19 public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = []) 20 public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = [])
20 { 21 {