作者 zhl

u cache

@@ -302,11 +302,11 @@ public function setEvent($id, $status, $note = '') @@ -302,11 +302,11 @@ public function setEvent($id, $status, $note = '')
302 302
303 if ($status == BtEvents::STATUS_ERROR && $times < BtEvents::MAX_TRIES_TIMES) { 303 if ($status == BtEvents::STATUS_ERROR && $times < BtEvents::MAX_TRIES_TIMES) {
304 $status = BtEvents::STATUS_INIT; 304 $status = BtEvents::STATUS_INIT;
305 - // 第一次执行失败以后, 5分钟后再执行一次; 第二次执行失败以后, 10分钟后再执行一次 0->5->15 305 + // 第一次执行失败以后, 15分钟后再执行一次; 第二次执行失败以后, 15分钟后再执行一次 0->15->30
306 if ($times == 1) 306 if ($times == 1)
307 - $event->start_at = date('Y-m-d H:i:s', time() + 300); 307 + $event->start_at = date('Y-m-d H:i:s', time() + 900);
308 if ($times == 2) 308 if ($times == 2)
309 - $event->start_at = date('Y-m-d H:i:s', time() + 600); 309 + $event->start_at = date('Y-m-d H:i:s', time() + 900);
310 } 310 }
311 $event->status = $status; 311 $event->status = $status;
312 $event->times = $times; 312 $event->times = $times;
@@ -51,7 +51,7 @@ public function deleteSite(Request $request) @@ -51,7 +51,7 @@ public function deleteSite(Request $request)
51 try { 51 try {
52 // $this->validate(); 52 // $this->validate();
53 $domain = $request->input('domain'); 53 $domain = $request->input('domain');
54 - if (empty($domain) || filter_var($domain, FILTER_VALIDATE_URL)) 54 + if (empty($domain) || FALSE == filter_var($domain, FILTER_VALIDATE_URL))
55 return $this->error('请提交有效domain信息'); 55 return $this->error('请提交有效domain信息');
56 56
57 $result = app(BtRepository::class)->deleteBtSite($domain); 57 $result = app(BtRepository::class)->deleteBtSite($domain);
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 10
11 use App\Models\BtSites; 11 use App\Models\BtSites;
12 use App\Repositories\Bt\Bt; 12 use App\Repositories\Bt\Bt;
  13 +use Illuminate\Filesystem\Cache;
13 14
14 /** 15 /**
15 * Class BtRepository 16 * Class BtRepository
@@ -177,10 +178,16 @@ public function applySsl($host) @@ -177,10 +178,16 @@ public function applySsl($host)
177 return true; 178 return true;
178 } 179 }
179 180
  181 +
  182 + if (Cache::get('apply_ssl_' . $host))
  183 + return false;
180 $domain = array_column($domain_list, 'name'); 184 $domain = array_column($domain_list, 'name');
181 $result = $bt->ApplyCert(json_encode($domain), $site->site_id); 185 $result = $bt->ApplyCert(json_encode($domain), $site->site_id);
182 - if (empty($result) || empty($result['cert'])) 186 + if (empty($result) || empty($result['cert'])) {
  187 + // 创建失败 host冻结15分钟
  188 + Cache::put('apply_ssl_' . $host, 1, 890);
183 return false; 189 return false;
  190 + }
184 191
185 $bt->SetSSL('1', $host, $result['private_key'], $result['cert']); 192 $bt->SetSSL('1', $host, $result['private_key'], $result['cert']);
186 // 开启强制https 193 // 开启强制https