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
14 changes: 14 additions & 0 deletions app/Providers/ServiceTypeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Services\PHP\PHP;
use App\Services\ProcessManager\Supervisor;
use App\Services\Redis\Redis;
use App\Services\Valkey\Valkey;
use App\Services\Webserver\Caddy;
use App\Services\Webserver\Nginx;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -129,6 +130,19 @@ private function memoryDatabases(): void
],
])
->register();

RegisterServiceType::make(Valkey::id())
->type(Valkey::type())
->label('Valkey')
->handler(Valkey::class)
->configPaths([
[
'name' => 'valkey.conf',
'path' => '/etc/valkey/valkey.conf',
'sudo' => true,
],
])
->register();
}

private function firewalls(): void
Expand Down
75 changes: 75 additions & 0 deletions app/Services/Valkey/Valkey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace App\Services\Valkey;

use App\Exceptions\ServiceInstallationFailed;
use App\Exceptions\SSHError;
use App\Services\AbstractService;
use Closure;

class Valkey extends AbstractService
{
public static function id(): string
{
return 'valkey';
}

public static function type(): string
{
return 'memory_database';
}

public function unit(): string
{
return 'valkey-server';
}

public function creationRules(array $input): array
{
return [
'type' => [
'required',
function (string $attribute, mixed $value, Closure $fail): void {
$memoryDatabaseExists = $this->service->server->memoryDatabase();
if ($memoryDatabaseExists) {
$fail('You already have a memory database service on the server.');
}
},
],
];
}

/**
* @throws ServiceInstallationFailed
* @throws SSHError
*/
public function install(): void
{
$this->service->server->ssh()->exec(
view('ssh.services.valkey.install'),
'install-valkey'
);
$status = $this->service->server->systemd()->status($this->unit());
$this->service->validateInstall($status);
event('service.installed', $this->service);
$this->service->server->os()->cleanup();
}

/**
* @throws SSHError
*/
public function uninstall(): void
{
$this->service->server->ssh()->exec(
view('ssh.services.valkey.uninstall'),
'uninstall-valkey'
);
event('service.uninstalled', $this->service);
$this->service->server->os()->cleanup();
}

public function version(): string
{
return $this->service->server->ssh()->exec("valkey-server --version | grep -oP 'v=\\K[0-9.]+'", 'get-valkey-version');
}
}
2 changes: 1 addition & 1 deletion resources/js/pages/databases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function Databases() {
</Button>
</a>
<SyncDatabases server={page.props.server} />
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
<Button>
<PlusIcon />
<span className="hidden lg:block">Create</span>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/pages/sites/components/create-site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ export default function CreateSite({
<DialogTitle>Why Isolated Users?</DialogTitle>
<DialogDescription>
Isolated users are mandatory to ensure security for your sites. If a site has security vulnerabilities and gets
compromised, the attacker cannot take full control of the server because the site runs under its own isolated user
with limited permissions.
compromised, the attacker cannot take full control of the server because the site runs under its own isolated user with
limited permissions.
</DialogDescription>
</DialogHeader>
</DialogContent>
Expand Down
7 changes: 7 additions & 0 deletions resources/views/ssh/services/valkey/install.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo DEBIAN_FRONTEND=noninteractive apt-get install valkey-server -y

sudo sed -i 's/bind 127.0.0.1 -::1/bind 0.0.0.0/g' /etc/valkey/valkey.conf

sudo systemctl enable valkey-server

sudo systemctl start valkey-server
12 changes: 12 additions & 0 deletions resources/views/ssh/services/valkey/uninstall.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sudo systemctl stop valkey-server

sudo DEBIAN_FRONTEND=noninteractive apt-get remove valkey-server -y

sudo rm -rf /etc/valkey
sudo rm -rf /var/lib/valkey
sudo rm -rf /var/log/valkey
sudo rm -rf /var/run/valkey

sudo DEBIAN_FRONTEND=noninteractive sudo apt-get autoremove -y

sudo DEBIAN_FRONTEND=noninteractive sudo apt-get autoclean -y
5 changes: 5 additions & 0 deletions tests/Feature/ServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ public static function installData(): array
'memory_database',
'latest',
],
[
'valkey',
'memory_database',
'latest',
],
[
'mysql',
'database',
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/SitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ public static function create_data(): array
'port' => '3000',
'repository' => 'test/test',
'branch' => 'main',
'user' => 'example',
],
],
[
Expand Down Expand Up @@ -695,6 +696,7 @@ public static function create_data(): array
'branch' => 'main',
'build_command' => 'pnpm run build:prod',
'start_command' => 'pnpm run start:prod',
'user' => 'example',
],
],
[
Expand All @@ -705,6 +707,7 @@ public static function create_data(): array
'port' => '3000',
'repository' => 'test/test',
'branch' => 'main',
'user' => 'example',
],
],
];
Expand Down