coolify/app/Http/Livewire/Server/Proxy/Deploy.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2023-06-02 15:15:12 +02:00
<?php
namespace App\Http\Livewire\Server\Proxy;
2023-09-14 16:55:13 +02:00
use App\Actions\Proxy\SaveConfigurationSync;
2023-07-14 13:38:24 +02:00
use App\Actions\Proxy\StartProxy;
2023-06-02 15:15:12 +02:00
use App\Models\Server;
use Livewire\Component;
class Deploy extends Component
{
public Server $server;
public $proxy_settings = null;
2023-09-11 22:29:34 +02:00
protected $listeners = ['proxyStatusUpdated'];
2023-09-11 22:29:34 +02:00
public function proxyStatusUpdated() {
$this->server->refresh();
}
public function startProxy()
2023-06-02 15:15:12 +02:00
{
if (
2023-06-20 20:19:31 +02:00
$this->server->proxy->last_applied_settings &&
$this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
2023-06-02 15:15:12 +02:00
) {
2023-09-14 17:10:37 +02:00
resolve(SaveConfigurationSync::class)($this->server);
2023-06-02 15:15:12 +02:00
}
2023-09-11 22:29:34 +02:00
2023-07-14 13:38:24 +02:00
$activity = resolve(StartProxy::class)($this->server);
2023-06-02 15:15:12 +02:00
$this->emit('newMonitorActivity', $activity->id);
}
2023-06-02 15:15:12 +02:00
public function stop()
{
instant_remote_process([
"docker rm -f coolify-proxy",
], $this->server);
2023-06-20 20:19:31 +02:00
$this->server->proxy->status = 'exited';
2023-06-02 15:15:12 +02:00
$this->server->save();
$this->emit('proxyStatusUpdated');
}
}