Skip to content

Commit bf78bbd

Browse files
authored
Use defined speedtest server (alexjustesen#7)
1 parent c3e3233 commit bf78bbd

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

app/Console/Commands/RunSpeedtest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ class RunSpeedtest extends Command
2929
*/
3030
public function handle()
3131
{
32-
ExecSpeedtest::dispatch();
32+
$speedtest = [];
33+
34+
if ($this->argument('server')) {
35+
$speedtest = array_merge($speedtest, ['ookla_server_id' => $this->argument('server')]);
36+
}
37+
38+
ExecSpeedtest::dispatch(speedtest: $speedtest);
3339

3440
$this->info('✅ added manual speedtest to the queue');
3541

app/Jobs/ExecSpeedtest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ public function __construct(
3333
*/
3434
public function handle()
3535
{
36-
$process = new Process(['speedtest', '--accept-license', '--format=json']);
36+
$args = [
37+
'speedtest',
38+
'--accept-license',
39+
'--format=json',
40+
];
41+
42+
if (! blank($this->speedtest)) {
43+
if (! blank($this->speedtest['ookla_server_id'])) {
44+
$args = array_merge($args, ['--server-id='.$this->speedtest['ookla_server_id']]);
45+
}
46+
}
47+
48+
$process = new Process($args);
3749
$process->run();
3850

3951
if (! $process->isSuccessful()) {

0 commit comments

Comments
 (0)