Skip to content

Commit

Permalink
Merge pull request #708 from TheRestartProject/RES-1956_discourse_que…
Browse files Browse the repository at this point in the history
…ue_blocker

RES-1956 Discourse problems blocking queue handler
  • Loading branch information
edwh authored Nov 27, 2023
2 parents 781345a + 0f2c48a commit d54f971
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Listeners/AddUserToDiscourseThreadForEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
use App\Services\DiscourseService;
use App\User;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Queue\InteractsWithQueue;

class AddUserToDiscourseThreadForEvent implements ShouldQueue {
private $discourseService;
public $tries = 1;

public function __construct(DiscourseService $discourseService)
{
Expand All @@ -28,6 +30,14 @@ private function getHost($idevents) {
}

public function handle(UserConfirmedEvent $e) {
// This call can block for a long time - add our own timeout so that we can fail it rather than block
// the whole queue.
pcntl_signal(SIGALRM, function () {
$this->fail();
});

pcntl_alarm(10);

if ($e->iduser) {
$event = Party::find($e->idevents);
$user = User::find($e->iduser);
Expand All @@ -46,5 +56,7 @@ public function handle(UserConfirmedEvent $e) {
}
}
}

pcntl_alarm(0);
}
}

0 comments on commit d54f971

Please sign in to comment.