mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 04:23:34 +00:00
feat(resources): add cross-server resource migration (dev-only) (#11165)
This commit is contained in:
@@ -102,6 +102,35 @@ function instant_scp(string $source, string $dest, Server $server, $throwError =
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a remote file from a managed server onto the Coolify host via SCP.
|
||||
*/
|
||||
function instant_scp_from_server(string $remoteSource, string $localDest, Server $server, $throwError = true)
|
||||
{
|
||||
return SshRetryHandler::retry(
|
||||
function () use ($remoteSource, $localDest, $server) {
|
||||
$scp_command = SshMultiplexingHelper::generateScpDownloadCommand($server, $remoteSource, $localDest);
|
||||
$process = Process::timeout(config('constants.ssh.command_timeout'))->run($scp_command);
|
||||
|
||||
$output = trim($process->output());
|
||||
$exitCode = $process->exitCode();
|
||||
|
||||
if ($exitCode !== 0) {
|
||||
excludeCertainErrors($process->errorOutput(), $exitCode);
|
||||
}
|
||||
|
||||
return $output === 'null' ? null : $output;
|
||||
},
|
||||
[
|
||||
'server' => $server->ip,
|
||||
'source' => $remoteSource,
|
||||
'dest' => $localDest,
|
||||
'function' => 'instant_scp_from_server',
|
||||
],
|
||||
$throwError
|
||||
);
|
||||
}
|
||||
|
||||
function instant_remote_process_with_timeout(Collection|array $command, Server $server, bool $throwError = true, bool $no_sudo = false): ?string
|
||||
{
|
||||
$command = $command instanceof Collection ? $command->toArray() : $command;
|
||||
|
||||
Reference in New Issue
Block a user