From 5501dd1325053d6836643862c24624080e716786 Mon Sep 17 00:00:00 2001 From: Sanja Date: Tue, 20 Feb 2024 09:01:21 -0800 Subject: [PATCH] Implement WithoutOverlapping to prevent job overlaps --- ProcessMaker/Jobs/BuildScriptExecutor.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ProcessMaker/Jobs/BuildScriptExecutor.php b/ProcessMaker/Jobs/BuildScriptExecutor.php index f83ee67703..ad09d207c2 100644 --- a/ProcessMaker/Jobs/BuildScriptExecutor.php +++ b/ProcessMaker/Jobs/BuildScriptExecutor.php @@ -6,6 +6,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; class BuildScriptExecutor implements ShouldQueue @@ -18,7 +19,7 @@ class BuildScriptExecutor implements ShouldQueue protected $userId; // Do not retry this job if it fails - public $tries = 1; + public $tries = 20; // Building can take some time public $timeout = 600; @@ -43,4 +44,12 @@ public function handle() { \Artisan::call('processmaker:build-script-executor ' . $this->lang . ' ' . $this->userId . ' --rebuild'); } + + /** + * Prevent job overlaps + */ + public function middleware(): array + { + return [(new WithoutOverlapping())->releaseAfter(10)]; + } }