mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
init
This commit is contained in:
49
app/Jobs/Queue/Deploy.php
Normal file
49
app/Jobs/Queue/Deploy.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Queue;
|
||||
|
||||
use App\Enums\QueueStatus;
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Queue;
|
||||
|
||||
class Deploy extends Job
|
||||
{
|
||||
protected Queue $worker;
|
||||
|
||||
public function __construct(Queue $worker)
|
||||
{
|
||||
$this->worker = $worker;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->worker->server->processManager()->handler()->create(
|
||||
$this->worker->id,
|
||||
$this->worker->command,
|
||||
$this->worker->user,
|
||||
$this->worker->auto_start,
|
||||
$this->worker->auto_restart,
|
||||
$this->worker->numprocs,
|
||||
$this->worker->log_file,
|
||||
$this->worker->site_id
|
||||
);
|
||||
$this->worker->status = QueueStatus::RUNNING;
|
||||
$this->worker->save();
|
||||
event(
|
||||
new Broadcast('deploy-queue-finished', [
|
||||
'queue' => $this->worker,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function failed(): void
|
||||
{
|
||||
$this->worker->delete();
|
||||
event(
|
||||
new Broadcast('deploy-queue-failed', [
|
||||
'queue' => $this->worker,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user