mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 08:42:38 -04:00
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Database;
|
|
|
|
use App\Models\StandaloneClickhouse;
|
|
use App\Models\StandaloneDragonfly;
|
|
use App\Models\StandaloneKeydb;
|
|
use App\Models\StandaloneMariadb;
|
|
use App\Models\StandaloneMongodb;
|
|
use App\Models\StandaloneMysql;
|
|
use App\Models\StandalonePostgresql;
|
|
use App\Models\StandaloneRedis;
|
|
use App\Models\StandaloneSqlite;
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
class RestartDatabase
|
|
{
|
|
use AsAction;
|
|
|
|
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $database)
|
|
{
|
|
$server = $database->destination->server;
|
|
if (! $server->isFunctional()) {
|
|
return 'Server is not functional';
|
|
}
|
|
$busyError = StartDatabase::operationInProgressError($database);
|
|
if ($busyError !== null) {
|
|
return $busyError;
|
|
}
|
|
$prerequisiteError = StartDatabase::prerequisiteError($database);
|
|
if ($prerequisiteError !== null) {
|
|
return $prerequisiteError;
|
|
}
|
|
StopDatabase::run($database, dockerCleanup: false);
|
|
|
|
return StartDatabase::run($database);
|
|
}
|
|
}
|