作者 Your Name
@@ -35,7 +35,7 @@ class CreateSite extends Command @@ -35,7 +35,7 @@ class CreateSite extends Command
35 if ($task) { 35 if ($task) {
36 $model->edit(['status' => DomainCreateTask::STATUS_ING], ['id' => $task['id']]); 36 $model->edit(['status' => DomainCreateTask::STATUS_ING], ['id' => $task['id']]);
37 37
38 - $re = $this->editDomainBt($task['domain_id']); 38 + $re = $this->editDomainBt($task['domain_id'], $task['type']);
39 39
40 if (is_array($re)) { 40 if (is_array($re)) {
41 $model->edit(['status' => DomainCreateTask::STATUS_FAL, 'error_msg' => $re[1]], ['id' => $task['id']]); 41 $model->edit(['status' => DomainCreateTask::STATUS_FAL, 'error_msg' => $re[1]], ['id' => $task['id']]);
@@ -45,7 +45,7 @@ class CreateSite extends Command @@ -45,7 +45,7 @@ class CreateSite extends Command
45 } 45 }
46 } 46 }
47 47
48 - protected function editDomainBt($domain_id) 48 + protected function editDomainBt($domain_id, $type)
49 { 49 {
50 //获取域名数据 50 //获取域名数据
51 $domain_model = new DomainInfo(); 51 $domain_model = new DomainInfo();
@@ -73,6 +73,7 @@ class CreateSite extends Command @@ -73,6 +73,7 @@ class CreateSite extends Command
73 return [false, '获取服务器数据失败2']; 73 return [false, '获取服务器数据失败2'];
74 } 74 }
75 75
  76 + if ($type == 1) {
76 /*****************编辑主站*******************/ 77 /*****************编辑主站*******************/
77 if ($domain_info['type'] == 2) { 78 if ($domain_info['type'] == 2) {
78 $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl'; 79 $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl';
@@ -101,17 +102,17 @@ class CreateSite extends Command @@ -101,17 +102,17 @@ class CreateSite extends Command
101 } 102 }
102 103
103 try { 104 try {
104 - $rs = HttpUtils::get($api_url, $api_param); 105 + $rs = HttpUtils::get($api_url, $api_param, [], 180);
105 $rs = json_decode($rs, true); 106 $rs = json_decode($rs, true);
106 if (isset($rs['status']) && $rs['status'] == 200) { 107 if (isset($rs['status']) && $rs['status'] == 200) {
107 $this->output($domain_info['domain'] . ',主站创建成功'); 108 $this->output($domain_info['domain'] . ',主站创建成功');
108 } else { 109 } else {
109 - return [false, '主站:' . ($rs['message'] ?? '未知错误')]; 110 + return [false, $rs['message'] ?? '未知错误'];
110 } 111 }
111 } catch (\Exception | GuzzleException $e) { 112 } catch (\Exception | GuzzleException $e) {
112 - return [false, '主站:' . $e->getMessage()]; 113 + return [false, $e->getMessage()];
113 } 114 }
114 - 115 + } else {
115 /*****************编辑amp站*******************/ 116 /*****************编辑amp站*******************/
116 if ($domain_info['amp_status']) { 117 if ($domain_info['amp_status']) {
117 $api_url_amp = 'http://' . $serverInfo['init_domain'] . '/api/createSiteAmp'; 118 $api_url_amp = 'http://' . $serverInfo['init_domain'] . '/api/createSiteAmp';
@@ -127,15 +128,16 @@ class CreateSite extends Command @@ -127,15 +128,16 @@ class CreateSite extends Command
127 } 128 }
128 129
129 try { 130 try {
130 - $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp); 131 + $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp, [], 180);
131 $rs_amp = json_decode($rs_amp, true); 132 $rs_amp = json_decode($rs_amp, true);
132 if (isset($rs_amp['status']) && $rs_amp['status'] == 200) { 133 if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {
133 $this->output($domain_info['domain'] . ',amp站创建成功'); 134 $this->output($domain_info['domain'] . ',amp站创建成功');
134 } else { 135 } else {
135 - return [false, 'amp站:' . ($rs['message'] ?? '未知错误')]; 136 + return [false, $rs['message'] ?? '未知错误'];
136 } 137 }
137 } catch (\Exception | GuzzleException $e_amp) { 138 } catch (\Exception | GuzzleException $e_amp) {
138 - return [false, 'amp站:' . $e_amp->getMessage()]; 139 + return [false, $e_amp->getMessage()];
  140 + }
139 } 141 }
140 } 142 }
141 143
@@ -39,18 +39,18 @@ class HttpUtils @@ -39,18 +39,18 @@ class HttpUtils
39 * @return int 39 * @return int
40 * @throws \GuzzleHttp\Exception\GuzzleException 40 * @throws \GuzzleHttp\Exception\GuzzleException
41 */ 41 */
42 - public static function get($url, $data, $headers = []) 42 + public static function get($url, $data, $headers = [],$timeout=60)
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::timeout(60)->withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout($timeout)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
49 49
50 - public static function post($url, $data, $headers = []) 50 + public static function post($url, $data, $headers = [],$timeout=60)
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::timeout(60)->withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout($timeout)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }