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