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

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