update: job timeout

This commit is contained in:
v2board 2023-04-04 17:58:25 +08:00
parent d4ac203805
commit 2f153acd51
6 changed files with 20 additions and 14 deletions

View File

@ -15,6 +15,8 @@ class OrderHandleJob implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $order; protected $order;
public $tries = 3;
public $timeout = 5;
/** /**
* Create a new job instance. * Create a new job instance.
* *

View File

@ -16,6 +16,8 @@ class SendEmailJob implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $params; protected $params;
public $tries = 3;
public $timeout = 10;
/** /**
* Create a new job instance. * Create a new job instance.
* *

View File

@ -16,7 +16,7 @@ class SendTelegramJob implements ShouldQueue
protected $text; protected $text;
public $tries = 3; public $tries = 3;
public $timeout = 5; public $timeout = 10;
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -19,7 +19,7 @@ class StatServerJob implements ShouldQueue
protected $recordType; protected $recordType;
public $tries = 3; public $tries = 3;
public $timeout = 60; public $timeout = 10;
/** /**
* Create a new job instance. * Create a new job instance.
@ -53,16 +53,8 @@ class StatServerJob implements ShouldQueue
->where('server_id', $this->server['id']) ->where('server_id', $this->server['id'])
->where('server_type', $this->protocol) ->where('server_type', $this->protocol)
->first(); ->first();
if ($data) {
try { if (!$data) {
$data->update([
'u' => $data['u'] + $this->u,
'd' => $data['d'] + $this->d
]);
} catch (\Exception $e) {
abort(500, '节点统计数据更新失败');
}
} else {
if (!StatServer::create([ if (!StatServer::create([
'server_id' => $this->server['id'], 'server_id' => $this->server['id'],
'server_type' => $this->protocol, 'server_type' => $this->protocol,
@ -73,6 +65,16 @@ class StatServerJob implements ShouldQueue
])) { ])) {
abort(500, '节点统计数据创建失败'); abort(500, '节点统计数据创建失败');
} }
return;
}
try {
$data->update([
'u' => $data['u'] + $this->u,
'd' => $data['d'] + $this->d
]);
} catch (\Exception $e) {
abort(500, '节点统计数据更新失败');
} }
} }
} }

View File

@ -21,7 +21,7 @@ class StatUserJob implements ShouldQueue
protected $recordType; protected $recordType;
public $tries = 3; public $tries = 3;
public $timeout = 60; public $timeout = 10;
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -20,7 +20,7 @@ class TrafficFetchJob implements ShouldQueue
protected $protocol; protected $protocol;
public $tries = 3; public $tries = 3;
public $timeout = 3; public $timeout = 10;
/** /**
* Create a new job instance. * Create a new job instance.