mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
init
This commit is contained in:
48
app/Jobs/Ssl/Deploy.php
Normal file
48
app/Jobs/Ssl/Deploy.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Ssl;
|
||||
|
||||
use App\Enums\SiteType;
|
||||
use App\Enums\SslStatus;
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Ssl;
|
||||
|
||||
class Deploy extends Job
|
||||
{
|
||||
protected Ssl $ssl;
|
||||
|
||||
public function __construct(Ssl $ssl)
|
||||
{
|
||||
$this->ssl = $ssl;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->ssl->site->server->webserver()->handler()->setupSSL($this->ssl);
|
||||
$this->ssl->status = SslStatus::CREATED;
|
||||
$this->ssl->save();
|
||||
event(
|
||||
new Broadcast('deploy-ssl-finished', [
|
||||
'ssl' => $this->ssl,
|
||||
])
|
||||
);
|
||||
if ($this->ssl->site->type == SiteType::WORDPRESS) {
|
||||
$typeData = $this->ssl->site->type_data;
|
||||
$typeData['url'] = $this->ssl->site->url;
|
||||
$this->ssl->site->type_data = $typeData;
|
||||
$this->ssl->site->save();
|
||||
$this->ssl->site->type()->edit();
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(): void
|
||||
{
|
||||
event(
|
||||
new Broadcast('deploy-ssl-failed', [
|
||||
'ssl' => $this->ssl,
|
||||
])
|
||||
);
|
||||
$this->ssl->delete();
|
||||
}
|
||||
}
|
39
app/Jobs/Ssl/Remove.php
Normal file
39
app/Jobs/Ssl/Remove.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Ssl;
|
||||
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Ssl;
|
||||
|
||||
class Remove extends Job
|
||||
{
|
||||
protected Ssl $ssl;
|
||||
|
||||
public function __construct(Ssl $ssl)
|
||||
{
|
||||
$this->ssl = $ssl;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->ssl->site->server->webserver()->handler()->removeSSL($this->ssl);
|
||||
$this->ssl->delete();
|
||||
event(
|
||||
new Broadcast('remove-ssl-finished', [
|
||||
'ssl' => $this->ssl,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function failed(): void
|
||||
{
|
||||
$this->ssl->status = 'failed';
|
||||
$this->ssl->save();
|
||||
event(
|
||||
new Broadcast('remove-ssl-failed', [
|
||||
'ssl' => $this->ssl,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user