mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 11:20:53 +08:00
feat: node traffic limit & batch operations
- Traffic monitoring with transfer_enable limit - Batch delete nodes - Reset traffic (single/batch)
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\StatServer;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -59,12 +61,23 @@ class StatServerJob implements ShouldQueue
|
||||
|
||||
try {
|
||||
$this->processServerStat($u, $d, $recordAt);
|
||||
$this->updateServerTraffic($u, $d);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('StatServerJob failed for server ' . $this->server['id'] . ': ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateServerTraffic(int $u, int $d): void
|
||||
{
|
||||
DB::table('v2_server')
|
||||
->where('id', $this->server['id'])
|
||||
->incrementEach(
|
||||
['u' => $u, 'd' => $d],
|
||||
['updated_at' => Carbon::now()]
|
||||
);
|
||||
}
|
||||
|
||||
protected function processServerStat(int $u, int $d, int $recordAt): void
|
||||
{
|
||||
$driver = config('database.default');
|
||||
|
||||
Reference in New Issue
Block a user