lundi 18 juillet 2022

laravel 5.7 job instance create but not execute

I have created jobs for video converting and updating in database in Laravel 5.7. All created jobs work correctly but any new job I am create in that only instance create but not execute. I have created one test email job with log entry.

My env file changes: .env

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120

In config folder: queue.php

'default' => env('QUEUE_CONNECTION', 'sync'),

'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'database' => [
            'driver' => 'database',
            'table' => 'jobs',
            'queue' => 'default',
            'retry_after' => 400000,
        ],

Job called by cron job custom command: TestEmail.php

MatchSendEmail::dispatch()->onQueue('queue_test');

My test mail job: MatchSendEmail.php

namespace App\Jobs;
use Mail;
use App\Mail\EmailTest;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class MatchSendEmail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        app('log')->info('supervisor send mail for all construct->');
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        app('log')->info('supervisor send mail for all handle');
        $email = new EmailTest();
        Mail::to(['******@gmail.com', 'ravi@****.com'])->send($email);
        app('log')->info('supervisor send mail for all handle1');
    }
}

I have used supervisor for background process and below is configuration file:

[program:queue_test]

process_name=%(program_name)s_%(process_num)02d

command=php /home/web1/******.com/htdocs/artisan queue:work --tries=10 --sleep=5

autostart=true

autorestart=true

user=web1

numprocs=20

redirect_stderr=true

stdout_logfile=/home/web1/******.com/htdocs/storage/logs/queue_test.log

Only job instance creates but not execute, please guide me how this issue resolve.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire