Laravel-Queue-Monitor icon indicating copy to clipboard operation
Laravel-Queue-Monitor copied to clipboard

Any thoughts on how this might be used to kill a running job?

Open oobi opened this issue 4 years ago • 1 comments

This is probably a feature request but I haven't found any good info on this in the Laravel docs.

Is there a way to hook the "delete" action on a running job to kill the task itself or interrupt it?

oobi avatar Jun 04 '21 07:06 oobi

Laravel does not include include any functionality like this out of the box. I've already implemented a similar functionality by storing the process ID in the queue data.

public function handle(): void
{
    if (function_exists('posix_getpid')) {
        $this->queueData(['process_id' => posix_getpid()]);
    }
}

You could you posix_kill to kill the process.

I'll look into this further and setup a PR 👍

romanzipp avatar Jun 11 '21 08:06 romanzipp