2023-10-14 12:22:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Database;
|
|
|
|
|
2023-11-09 13:59:38 +00:00
|
|
|
use App\Models\ServiceDatabase;
|
2024-04-10 13:00:46 +00:00
|
|
|
use App\Models\StandaloneClickhouse;
|
|
|
|
use App\Models\StandaloneDragonfly;
|
|
|
|
use App\Models\StandaloneKeydb;
|
2023-10-24 12:31:28 +00:00
|
|
|
use App\Models\StandaloneMariadb;
|
2023-10-19 11:32:03 +00:00
|
|
|
use App\Models\StandaloneMongodb;
|
2023-10-24 12:31:28 +00:00
|
|
|
use App\Models\StandaloneMysql;
|
2023-10-14 12:22:07 +00:00
|
|
|
use App\Models\StandalonePostgresql;
|
|
|
|
use App\Models\StandaloneRedis;
|
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
|
|
|
|
class StopDatabaseProxy
|
|
|
|
{
|
|
|
|
use AsAction;
|
|
|
|
|
2024-04-10 13:00:46 +00:00
|
|
|
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|ServiceDatabase|StandaloneDragonfly|StandaloneClickhouse $database)
|
2023-10-14 12:22:07 +00:00
|
|
|
{
|
2023-11-09 13:59:38 +00:00
|
|
|
$server = data_get($database, 'destination.server');
|
2024-03-25 11:17:52 +00:00
|
|
|
$uuid = $database->uuid;
|
2023-11-09 13:59:38 +00:00
|
|
|
if ($database->getMorphClass() === 'App\Models\ServiceDatabase') {
|
2024-03-25 11:17:52 +00:00
|
|
|
$uuid = $database->service->uuid;
|
2023-11-09 13:59:38 +00:00
|
|
|
$server = data_get($database, 'service.server');
|
|
|
|
}
|
2024-03-25 11:17:52 +00:00
|
|
|
instant_remote_process(["docker rm -f {$uuid}-proxy"], $server);
|
2023-10-14 12:22:07 +00:00
|
|
|
$database->is_public = false;
|
|
|
|
$database->save();
|
|
|
|
}
|
|
|
|
}
|