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);
|
$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);
|
return redirect()->route('destination.show', $docker->uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ public function upgrade()
|
|||||||
if (!$server) {
|
if (!$server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instantRemoteProcess($server, [
|
instantRemoteProcess([
|
||||||
"sleep 2"
|
"sleep 2"
|
||||||
]);
|
], $server);
|
||||||
remoteProcess([
|
remoteProcess([
|
||||||
"sleep 10"
|
"sleep 10"
|
||||||
], $server, ActivityTypes::INLINE->value);
|
], $server, ActivityTypes::INLINE->value);
|
||||||
@ -32,15 +32,16 @@ public function upgrade()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instantRemoteProcess($server, [
|
instantRemoteProcess([
|
||||||
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
|
"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/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/.env.production -o /data/coolify/source/.env.production",
|
||||||
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||||
]);
|
], $server);
|
||||||
instantRemoteProcess($server, [
|
|
||||||
|
instantRemoteProcess([
|
||||||
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
||||||
]);
|
], $server);
|
||||||
|
|
||||||
remoteProcess([
|
remoteProcess([
|
||||||
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
||||||
|
@ -73,7 +73,7 @@ public function delete()
|
|||||||
}
|
}
|
||||||
public function stop()
|
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') {
|
if ($this->application->status != 'exited') {
|
||||||
$this->application->status = 'exited';
|
$this->application->status = 'exited';
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server;
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Enums\ActivityTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@ -28,15 +29,22 @@ public function mount()
|
|||||||
public function installDocker()
|
public function installDocker()
|
||||||
{
|
{
|
||||||
$config = base64_encode('{ "live-restore": true }');
|
$config = base64_encode('{ "live-restore": true }');
|
||||||
instantRemoteProcess($this->server, [
|
remoteProcess([
|
||||||
"curl https://releases.rancher.com/install-docker/23.0.sh | sh"
|
"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()
|
public function checkServer()
|
||||||
{
|
{
|
||||||
$this->uptime = instantRemoteProcess($this->server, ['uptime']);
|
try {
|
||||||
$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);
|
$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()
|
public function submit()
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ protected function checkAllServers()
|
|||||||
$not_found_applications = $applications;
|
$not_found_applications = $applications;
|
||||||
$containers = collect();
|
$containers = collect();
|
||||||
foreach ($servers as $server) {
|
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));
|
$containers = $containers->concat(formatDockerCmdOutputToJson($output));
|
||||||
}
|
}
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
@ -67,7 +67,7 @@ protected function checkContainerStatus()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($application->destination->server) {
|
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);
|
$container = formatDockerCmdOutputToJson($container);
|
||||||
$application->status = $container[0]['Status'];
|
$application->status = $container[0]['Status'];
|
||||||
$application->save();
|
$application->save();
|
||||||
|
@ -31,7 +31,7 @@ public function handle(): void
|
|||||||
try {
|
try {
|
||||||
$servers = Server::all();
|
$servers = Server::all();
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
instantRemoteProcess($server, ['docker image prune -f']);
|
instantRemoteProcess(['docker image prune -f'], $server);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
@ -120,7 +120,7 @@ function formatDockerLabelsToJson($rawOutput): Collection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!function_exists('instantRemoteProcess')) {
|
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);
|
$command_string = implode("\n", $command);
|
||||||
$private_key_location = savePrivateKeyForServer($server);
|
$private_key_location = savePrivateKeyForServer($server);
|
||||||
|
Loading…
Reference in New Issue
Block a user