2023-06-02 13:15:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Server\Proxy;
|
|
|
|
|
|
|
|
use App\Actions\Proxy\InstallProxy;
|
|
|
|
use App\Models\Server;
|
|
|
|
use Livewire\Component;
|
|
|
|
use Str;
|
|
|
|
|
|
|
|
class Deploy extends Component
|
|
|
|
{
|
|
|
|
public Server $server;
|
|
|
|
public $proxy_settings = null;
|
2023-07-14 11:01:55 +00:00
|
|
|
protected $listeners = ['proxyStatusUpdated'];
|
2023-06-02 13:15:12 +00:00
|
|
|
public function proxyStatusUpdated()
|
|
|
|
{
|
|
|
|
$this->server->refresh();
|
|
|
|
}
|
|
|
|
public function deploy()
|
|
|
|
{
|
|
|
|
if (
|
2023-06-20 18:19:31 +00:00
|
|
|
$this->server->proxy->last_applied_settings &&
|
|
|
|
$this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
|
2023-06-02 13:15:12 +00:00
|
|
|
) {
|
|
|
|
$this->saveConfiguration($this->server);
|
|
|
|
}
|
|
|
|
$activity = resolve(InstallProxy::class)($this->server);
|
|
|
|
$this->emit('newMonitorActivity', $activity->id);
|
|
|
|
}
|
|
|
|
public function stop()
|
|
|
|
{
|
|
|
|
instant_remote_process([
|
|
|
|
"docker rm -f coolify-proxy",
|
|
|
|
], $this->server);
|
2023-06-20 18:19:31 +00:00
|
|
|
$this->server->proxy->status = 'exited';
|
2023-06-02 13:15:12 +00:00
|
|
|
$this->server->save();
|
|
|
|
$this->emit('proxyStatusUpdated');
|
|
|
|
}
|
|
|
|
private function saveConfiguration(Server $server)
|
|
|
|
{
|
|
|
|
$this->emit('saveConfiguration', $server);
|
|
|
|
}
|
|
|
|
}
|