2023-10-14 12:22:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Database;
|
|
|
|
|
2023-12-11 08:02:53 +00:00
|
|
|
use App\Events\DatabaseStatusChanged;
|
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 StopDatabase
|
|
|
|
{
|
|
|
|
use AsAction;
|
|
|
|
|
2023-10-24 12:31:28 +00:00
|
|
|
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $database)
|
2023-10-14 12:22:07 +00:00
|
|
|
{
|
|
|
|
$server = $database->destination->server;
|
|
|
|
instant_remote_process(
|
|
|
|
["docker rm -f {$database->uuid}"],
|
|
|
|
$server
|
|
|
|
);
|
|
|
|
if ($database->is_public) {
|
|
|
|
StopDatabaseProxy::run($database);
|
|
|
|
}
|
|
|
|
// TODO: make notification for services
|
|
|
|
// $database->environment->project->team->notify(new StatusChanged($database));
|
|
|
|
}
|
|
|
|
}
|