Refactoring: extract process handling from async job.
This commit is contained in:
@@ -1,19 +1,29 @@
|
||||
<?php
|
||||
|
||||
use App\Actions\RemoteProcess\DispatchRemoteProcess;
|
||||
use App\Data\RemoteProcessArgs;
|
||||
use Spatie\Activitylog\Contracts\Activity;
|
||||
|
||||
if (! function_exists('remoteProcess')) {
|
||||
|
||||
/**
|
||||
* Run a Coolify Process, which SSH's into a machine to run the command(s).
|
||||
* Run a Coolify Process, which SSH's asynchronously into a machine to run the command(s).
|
||||
* @TODO Change 'root' to 'coolify' when it's able to run Docker commands without sudo
|
||||
*
|
||||
*/
|
||||
function remoteProcess($command, $destination): Activity
|
||||
function remoteProcess(
|
||||
string $command,
|
||||
string $destination,
|
||||
?int $port = 22,
|
||||
?string $user = 'root',
|
||||
): Activity
|
||||
{
|
||||
return resolve(DispatchRemoteProcess::class, [
|
||||
'destination' => $destination,
|
||||
'command' => $command,
|
||||
'remoteProcessArgs' => new RemoteProcessArgs(
|
||||
destination: $destination,
|
||||
command: $command,
|
||||
port: $port,
|
||||
user: $user,
|
||||
),
|
||||
])();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user