mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-04 19:49:16 +00:00
预防 vnet 任务被错误打断
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Jobs\VNet;
|
||||
use App\Models\Node;
|
||||
use App\Models\User;
|
||||
use Arr;
|
||||
use Exception;
|
||||
use Http;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -55,14 +56,18 @@ class addUser implements ShouldQueue
|
||||
|
||||
private function send(string $host, string $secret): void
|
||||
{
|
||||
$response = Http::baseUrl($host)->timeout(20)->withHeaders(['secret' => $secret])->post('api/v2/user/add/list', $this->data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::alert("【新增用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
} else {
|
||||
Log::notice("【新增用户】推送成功(推送地址:{$host},内容:".json_encode($this->data, true).')');
|
||||
try {
|
||||
$response = Http::baseUrl($host)->timeout(20)->withHeaders(['secret' => $secret])->post('api/v2/user/add/list', $this->data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::alert("【新增用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
} else {
|
||||
Log::notice("【新增用户】推送成功(推送地址:{$host},内容:".json_encode($this->data, true).')');
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
Log::alert('【新增用户】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Jobs\VNet;
|
||||
|
||||
use Arr;
|
||||
use Exception;
|
||||
use Http;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -43,21 +44,25 @@ class delUser implements ShouldQueue
|
||||
|
||||
private function send(string $host, string $secret): void
|
||||
{
|
||||
$request = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret]);
|
||||
try {
|
||||
$request = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret]);
|
||||
|
||||
if (is_array($this->userIds)) {
|
||||
$response = $request->post('api/v2/user/del/list', $this->userIds);
|
||||
} else {
|
||||
$response = $request->post('api/user/del/'.$this->userIds);
|
||||
}
|
||||
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::alert("【删除用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
if (is_array($this->userIds)) {
|
||||
$response = $request->post('api/v2/user/del/list', $this->userIds);
|
||||
} else {
|
||||
Log::notice("【删除用户】推送成功(推送地址:{$host},内容:".json_encode($this->userIds, true).')');
|
||||
$response = $request->post('api/user/del/'.$this->userIds);
|
||||
}
|
||||
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::alert("【删除用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
} else {
|
||||
Log::notice("【删除用户】推送成功(推送地址:{$host},内容:".json_encode($this->userIds, true).')');
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
Log::alert('【删除用户】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Jobs\VNet;
|
||||
|
||||
use App\Models\User;
|
||||
use Arr;
|
||||
use Exception;
|
||||
use Http;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -68,20 +69,24 @@ class editUser implements ShouldQueue
|
||||
|
||||
private function send(string $host, string $secret): void
|
||||
{
|
||||
$response = Http::baseUrl($host)->timeout(20)->withHeaders(['secret' => $secret])->post('api/user/edit', $this->data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::warning("【编辑用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
} else {
|
||||
Log::info("【编辑用户】推送成功(推送地址:{$host},内容:".json_encode($this->data, true).')');
|
||||
try {
|
||||
$response = Http::baseUrl($host)->timeout(20)->withHeaders(['secret' => $secret])->post('api/user/edit', $this->data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::warning("【编辑用户】推送失败(推送地址:{$host},返回内容:".$message['content'].')');
|
||||
} else {
|
||||
Log::info("【编辑用户】推送成功(推送地址:{$host},内容:".json_encode($this->data, true).')');
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
Log::alert('【编辑用户】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 队列失败处理
|
||||
public function failed(Throwable $exception)
|
||||
{
|
||||
Log::warning('【编辑用户】推送异常:'.$exception->getMessage());
|
||||
Log::alert('【编辑用户】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Jobs\VNet;
|
||||
|
||||
use App\Http\Controllers\Api\WebApi\SSRController;
|
||||
use Arr;
|
||||
use Exception;
|
||||
use Http;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -54,20 +55,24 @@ class reloadNode implements ShouldQueue
|
||||
|
||||
public function send(string $host, string $secret, array $data): bool
|
||||
{
|
||||
$response = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret])->post('api/v2/node/reload', $data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::warning("【重载节点】失败:{$host} 反馈:".$message['content']);
|
||||
try {
|
||||
$response = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret])->post('api/v2/node/reload', $data);
|
||||
$message = $response->json();
|
||||
if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) {
|
||||
if ($message['success'] === 'false') {
|
||||
Log::warning("【重载节点】失败:{$host} 反馈:".$message['content']);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Log::notice("【重载节点】成功:{$host} 反馈:".$message['content']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::notice("【重载节点】成功:{$host} 反馈:".$message['content']);
|
||||
|
||||
return true;
|
||||
Log::warning("【重载节点】失败:{$host}");
|
||||
} catch (Exception $exception) {
|
||||
Log::alert('【重载节点】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
Log::warning("【重载节点】失败:{$host}");
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -75,6 +80,6 @@ class reloadNode implements ShouldQueue
|
||||
// 队列失败处理
|
||||
public function failed(Throwable $exception)
|
||||
{
|
||||
Log::error('【重载节点】推送异常:'.$exception->getMessage());
|
||||
Log::alert('【重载节点】推送异常:'.$exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user