How to execute several Artisan commands without waiting for completion to complete?

I have a huge amount of data that I want to process quickly and get most of my server. So, I created one parent artisan team and one team for the children's craft .

Parent Wizard Team . Gets the value from the database, performs all the calculations, splits the data into pieces, and executes multiple instances of the child artisan command using the following code.

foreach($arrayOfData as $chunk){ // $arrayOfData is an array of Chunks
    $this->call('process:data',[
        'data' => $chunk  // Chunk is an array containing data
    ]);

    $this->info('Chunk Processed');
}

But he expects one instance to stop execution, which means that he does not immediately execute multiple instances of the children's artisan commands that I want! I know that calling this method will wait until one instance of the child artisan command stops execution. Is there a way I can execute multiple instances child artisan commandwithout waiting for one instance to stop execution?

I already looked for different ways to do this, I can execute child artisan commands using exec()similar functions, but it will also return an exit code for which my code will wait.

Performing only two instances at a time, I can divide the time for data processing by 2. And I want to execute three instances at once! Is there any way to do this?

Additional Information

Child artisan: . , .

+4
1

:

queue Artisan, Artisan, . , ,

foreach($arrayOfData as $chunk){ // $arrayOfData is an array of Chunks
    $this->queue('process:data',[
        'data' => $chunk  // Chunk is an array containing data
    ]);
}

, .

+4

Source: https://habr.com/ru/post/1692479/


All Articles