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