Skip to content

Commit 7d7bf95

Browse files
authored
feat: spread esi load for killmails and contracts (#416)
* feat: spread esi load for killmails and contracts * style: styleci
1 parent dc9ec82 commit 7d7bf95

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of SeAT
5+
*
6+
* Copyright (C) 2015 to present Leon Jacobs
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License along
19+
* with this program; if not, write to the Free Software Foundation, Inc.,
20+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*/
22+
23+
use Illuminate\Database\Migrations\Migration;
24+
use Illuminate\Support\Facades\DB;
25+
26+
return new class extends Migration {
27+
/**
28+
* Run the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function up()
33+
{
34+
// Where the default schedule exists for the killmail and contracts schedules,
35+
// remove it so it gets updated randomised
36+
DB::table('schedules')
37+
->whereIn('command', ['esi:update:contracts', 'esi:update:killmails'])
38+
->where('expression', '*/15 * * * *')
39+
->delete();
40+
}
41+
42+
/**
43+
* Reverse the migrations.
44+
*
45+
* @return void
46+
*/
47+
public function down()
48+
{
49+
// Nothing to do here. We dont want to go back
50+
}
51+
};

src/database/seeders/ScheduleSeeder.php

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ private function seedRandomize($schedules): array
183183
case 'esi:update:sovereignty':
184184
$schedules[$key]['expression'] = sprintf('%d %d * * *', rand(0, 59), Arr::random($hours));
185185
break;
186+
// 15 minute schedule with random offset
187+
case 'esi:update:killmails':
188+
case 'esi:update:contracts':
189+
$start = rand(1, 14); // Also dont include 0 as that is what all other people who use */15 will hit
190+
$schedules[$key]['expression'] = sprintf('%d,%d,%d,%d * * * *', $start, $start + 15, $start + 30, $start + 45);
191+
break;
186192
}
187193
}
188194

0 commit comments

Comments
 (0)