destination->server; if (! $server->isFunctional()) { return 'Server is not functional'; } $this->stopContainer($database, $database->uuid, 30); if ($dockerCleanup) { CleanupDocker::dispatch($server, false, false); } if ($database->is_public) { StopDatabaseProxy::run($database); } return 'Database stopped successfully'; } catch (\Exception $e) { return 'Database stop failed: '.$e->getMessage(); } finally { ServiceStatusChanged::dispatch($database->environment->project->team->id); } } private function stopContainer($database, string $containerName, int $timeout = 30): void { $server = $database->destination->server; instant_remote_process(command: [ "docker stop --time=$timeout $containerName", "docker rm -f $containerName", ], server: $server, throwError: false); } }