-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
Description
Description
Logs from an asynchronous job in a Laravel queue are not sent to CloudWatch until you shutdown the queue process.
This is because php artisan queue:work does not close the process. Queue workers do not "reboot" the framework before processing each job.
How to reproduce
- Create a new job:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class TestJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle()
{
Log::info('The job has been executed');
}
}- Create a new route:
use App\Jobs\TestJob;
Route::get('dispatch-job', function () {
TestJob::dispatch();
});- Run the queue:
php artisan queue:work
Note: make sure that in your .env you do not use the sync queue driver.
- Call
GET /dispatch-job
You will receive the logs in CloudWatch only when you'll interrupt the queue:work command. Not before.
Related GitHub issues
mugisham