harhoo's avatar

Using queues to process repeated tasks

So my use case is this:

I have a directory of 25000 images. I need to perform a a set of tasks on each image (resize it, upload it to S3, write a filename hash to a database).

I have the code all set to take the next image and then process it.

How do I start a queue and then stop it once all files are processed?

This is what I have:

class ProcessFile {
    public function fire($job, $data)
    {
    //below runs the task
    $this->process->nextFile();
    $job->release(); //needed to put it back on the queue?
    }
} 

Then do I need to launch the initial job? How do I do that? Use php artisan tinker and do Queue::push('ProcessFile')?

And then run php artisan queue:work connection --daemon

How do I stop it? php artisan queue:restart? Or something else?

If I want to run more than one worker, do I run php artisan listen more than once?

0 likes
0 replies

Please or to participate in this conversation.