feat: check local horizon scheduler deployments
This commit is contained in:
39
app/Actions/Application/AnyDeploymentsRunning.php
Normal file
39
app/Actions/Application/AnyDeploymentsRunning.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Application;
|
||||
|
||||
use Laravel\Horizon\Contracts\JobRepository;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class AnyDeploymentsRunning
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$hostname = gethostname();
|
||||
$recent = app(JobRepository::class)->getRecent();
|
||||
if ($recent) {
|
||||
$running = $recent->filter(function ($job) use ($hostname) {
|
||||
$payload = json_decode($job->payload);
|
||||
$tags = data_get($payload, 'tags');
|
||||
|
||||
return $job->status != 'completed' &&
|
||||
$job->status != 'failed' &&
|
||||
isset($tags) &&
|
||||
is_array($tags) &&
|
||||
in_array('server:'.$hostname, $tags);
|
||||
});
|
||||
if ($running->count() > 0) {
|
||||
dump($running);
|
||||
echo 'true';
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
echo 'false';
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -225,6 +225,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
public function tags(): array
|
||||
{
|
||||
return ['server:'.gethostname()];
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->application_deployment_queue->update([
|
||||
|
Reference in New Issue
Block a user