use same args for remoteProcess and instantRemoteProcess
This commit is contained in:
parent
3e475d87eb
commit
ad671cfcf1
@ -45,7 +45,7 @@ public function submit()
|
||||
|
||||
$server = Server::find($this->server_id);
|
||||
|
||||
instantRemoteProcess($server, ['docker network create --attachable ' . $this->network], throwError: false);
|
||||
instantRemoteProcess(['docker network create --attachable ' . $this->network], $server, throwError: false);
|
||||
return redirect()->route('destination.show', $docker->uuid);
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ public function upgrade()
|
||||
if (!$server) {
|
||||
return;
|
||||
}
|
||||
instantRemoteProcess($server, [
|
||||
instantRemoteProcess([
|
||||
"sleep 2"
|
||||
]);
|
||||
], $server);
|
||||
remoteProcess([
|
||||
"sleep 10"
|
||||
], $server, ActivityTypes::INLINE->value);
|
||||
@ -32,15 +32,16 @@ public function upgrade()
|
||||
return;
|
||||
}
|
||||
|
||||
instantRemoteProcess($server, [
|
||||
instantRemoteProcess([
|
||||
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
|
||||
"curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
|
||||
"curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production",
|
||||
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||
]);
|
||||
instantRemoteProcess($server, [
|
||||
], $server);
|
||||
|
||||
instantRemoteProcess([
|
||||
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
||||
]);
|
||||
], $server);
|
||||
|
||||
remoteProcess([
|
||||
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
||||
|
@ -73,7 +73,7 @@ public function delete()
|
||||
}
|
||||
public function stop()
|
||||
{
|
||||
instantRemoteProcess($this->destination->server, ["docker rm -f {$this->application->uuid}"]);
|
||||
instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server);
|
||||
if ($this->application->status != 'exited') {
|
||||
$this->application->status = 'exited';
|
||||
$this->application->save();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Enums\ActivityTypes;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Livewire\Component;
|
||||
@ -28,15 +29,22 @@ public function mount()
|
||||
public function installDocker()
|
||||
{
|
||||
$config = base64_encode('{ "live-restore": true }');
|
||||
instantRemoteProcess($this->server, [
|
||||
"curl https://releases.rancher.com/install-docker/23.0.sh | sh"
|
||||
]);
|
||||
remoteProcess([
|
||||
"curl https://releases.rancher.com/install-docker/23.0.sh | sh",
|
||||
"echo '{$config}' | base64 -d > /etc/docker/daemon.json",
|
||||
"systemctl restart docker"
|
||||
], $this->server, ActivityTypes::INLINE->value);
|
||||
}
|
||||
public function checkServer()
|
||||
{
|
||||
$this->uptime = instantRemoteProcess($this->server, ['uptime']);
|
||||
$this->dockerVersion = instantRemoteProcess($this->server, ['docker version|head -2|grep -i version'], false);
|
||||
$this->dockerComposeVersion = instantRemoteProcess($this->server, ['docker compose version|head -2|grep -i version'], false);
|
||||
try {
|
||||
|
||||
$this->uptime = instantRemoteProcess(['uptime'], $this->server);
|
||||
$this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false);
|
||||
$this->dockerComposeVersion = instantRemoteProcess(['docker compose version|head -2|grep -i version'], $this->server, false);
|
||||
} catch (\Exception $e) {
|
||||
$this->addError('server.ip', $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ protected function checkAllServers()
|
||||
$not_found_applications = $applications;
|
||||
$containers = collect();
|
||||
foreach ($servers as $server) {
|
||||
$output = instantRemoteProcess($server, ['docker ps -a -q --format \'{{json .}}\'']);
|
||||
$output = instantRemoteProcess(['docker ps -a -q --format \'{{json .}}\''], $server);
|
||||
$containers = $containers->concat(formatDockerCmdOutputToJson($output));
|
||||
}
|
||||
foreach ($containers as $container) {
|
||||
@ -67,7 +67,7 @@ protected function checkContainerStatus()
|
||||
return;
|
||||
}
|
||||
if ($application->destination->server) {
|
||||
$container = instantRemoteProcess($application->destination->server, ["docker inspect --format '{{json .State}}' {$this->container_id}"]);
|
||||
$container = instantRemoteProcess(["docker inspect --format '{{json .State}}' {$this->container_id}"], $application->destination->server);
|
||||
$container = formatDockerCmdOutputToJson($container);
|
||||
$application->status = $container[0]['Status'];
|
||||
$application->save();
|
||||
|
@ -31,7 +31,7 @@ public function handle(): void
|
||||
try {
|
||||
$servers = Server::all();
|
||||
foreach ($servers as $server) {
|
||||
instantRemoteProcess($server, ['docker image prune -f']);
|
||||
instantRemoteProcess(['docker image prune -f'], $server);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
@ -120,7 +120,7 @@ function formatDockerLabelsToJson($rawOutput): Collection
|
||||
}
|
||||
}
|
||||
if (!function_exists('instantRemoteProcess')) {
|
||||
function instantRemoteProcess(Server $server, array $command, $throwError = true)
|
||||
function instantRemoteProcess(array $command, Server $server, $throwError = true)
|
||||
{
|
||||
$command_string = implode("\n", $command);
|
||||
$private_key_location = savePrivateKeyForServer($server);
|
||||
|
Loading…
Reference in New Issue
Block a user