Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions app/Actions/Librespeed/RunSpeedtest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace App\Actions\Librespeed;

use App\Enums\ResultService;
use App\Enums\ResultStatus;
use App\Events\SpeedtestWaiting;
use App\Models\Result;
use Lorisleiva\Actions\Concerns\AsAction;
use Throwable;

class RunSpeedtest
{
use AsAction;

public function handle(bool $isScheduled = false, ?string $server = null, ?int $dispatchedBy = null): mixed
{
$result = Result::create([
'data->server->url' => $server,
'service' => ResultService::Librespeed,
'status' => ResultStatus::Waiting,
'scheduled' => $isScheduled,
'dispatched_by' => $dispatchedBy,
]);

SpeedtestWaiting::dispatch($result);

// TODO: Implement Librespeed speedtest job batching

// Bus::batch([
// [
// new StartSpeedtestJob($result),
// new CheckForInternetConnectionJob($result),
// new SkipSpeedtestJob($result),
// new SelectSpeedtestServerJob($result),
// new RunSpeedtestJob($result),
// new BenchmarkSpeedtestJob($result),
// new CompleteSpeedtestJob($result),
// ],
// ])->catch(function (Batch $batch, ?Throwable $e) {
// Log::error(sprintf('Speedtest batch "%s" failed for an unknown reason.', $batch->id));
// })->name('Ookla Speedtest')->dispatch();

return $result;
}
}
2 changes: 2 additions & 0 deletions app/Enums/ResultService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
enum ResultService: string implements HasLabel
{
case Faker = 'faker';
case Librespeed = 'librespeed';
case Ookla = 'ookla';

public function getLabel(): ?string
{
return match ($this) {
self::Faker => __('enums.service.faker'),
self::Librespeed => __('enums.service.librespeed'),
self::Ookla => __('enums.service.ookla'),
};
}
Expand Down
6 changes: 6 additions & 0 deletions docker/8.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARG NODE_VERSION=22
ARG MYSQL_CLIENT="mysql-client"
ARG POSTGRES_VERSION=17
ARG SPEEDTEST_VERSION=1.2.0
ARG LIBRESPEED_VERSION=1.0.12

WORKDIR /var/www/html

Expand Down Expand Up @@ -49,14 +50,19 @@ RUN apt-get update && apt-get upgrade -y \
&& ARCH=$(uname -m) \
&& if [ "$ARCH" = "x86_64" ]; then \
PLATFORM="x86_64"; \
LIBRESPEED_PLATFORM="amd64"; \
elif [ "$ARCH" = "aarch64" ]; then \
PLATFORM="aarch64"; \
LIBRESPEED_PLATFORM="arm64"; \
else \
echo "Unsupported architecture: $ARCH"; exit 1; \
fi \
&& curl -o /tmp/speedtest-cli.tgz -L \
"https://install.speedtest.net/app/cli/ookla-speedtest-$SPEEDTEST_VERSION-linux-$PLATFORM.tgz" \
&& tar -xzf /tmp/speedtest-cli.tgz -C /usr/bin \
&& curl -o /tmp/librespeed-cli.tar.gz -L \
"https://github.com/librespeed/speedtest-cli/releases/download/v$LIBRESPEED_VERSION/librespeed-cli_${LIBRESPEED_VERSION}_linux_${LIBRESPEED_PLATFORM}.tar.gz" \
&& tar -xzf /tmp/librespeed-cli.tar.gz -C /usr/bin \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand Down