coolify/app/Http/Livewire/RunCommand.php

55 lines
1.2 KiB
PHP
Raw Normal View History

2023-03-20 13:04:22 +01:00
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class RunCommand extends Component
{
public $activity;
public $isKeepAliveOn = false;
public $manualKeepAlive = false;
public $command = 'ls';
2023-03-20 13:04:22 +01:00
public function render()
{
return view('livewire.run-command');
}
public function runCommand()
{
$this->isKeepAliveOn = true;
$this->activity = remoteProcess($this->command, 'testing-host');
2023-03-20 13:04:22 +01:00
}
public function runSleepingBeauty()
{
$this->isKeepAliveOn = true;
$this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host');
}
public function runDummyProjectBuild()
{
$this->isKeepAliveOn = true;
$this->activity = remoteProcess(<<<EOT
cd projects/dummy-project
~/.docker/cli-plugins/docker-compose build --no-cache
EOT, 'testing-host');
}
2023-03-20 13:04:22 +01:00
public function polling()
{
$this->activity?->refresh();
if (data_get($this->activity, 'properties.exitCode') !== null) {
2023-03-20 13:04:22 +01:00
$this->isKeepAliveOn = false;
}
}
}