skip to Main Content

I have a laravel queue setup with a

database

Connection. Note this problem is also on redis. But i am currently using the database connection for the

failed_jobs

Table to help me check any errors that occur during the queue process.

The problem i have is that the queue stops working after a few jobs without any message showing why. But when i restart the command (php artisan queue:work) it picks up the remaining jobs. And continues. (But stops again later)

The job is configured with these values

public $tries = 1;
public $timeout = 10;

The job code is, (Not original code)

    public function handle()
    {
        try {
            $file = //function to create file;
            $zip = new ZipArchive();
            $zip->open(//zip_path);
            $zip->addFile(//file_path, //file_name);
            $zip->close();
            @unlink(//remove file);
        } catch (Exception $e) {
            Log::error($e);
        }
    }

And the failed function is setup like this:

public function failed(Exception $exception)
{
    Log::error($exception);
    $this->fail($exception);
    $this->delete();
}

But my there is no failed_job row, And my log is empty

Edit: I added simple info logs after every line of code. And every time i start the queue, It stops after the last line. So the code runs correct. So laravel doesn’t start the new job after that

3

Answers


  1. Did you tried queue:listen ?

    php artisan queue:listen
    

    Also i guess you need the Supervisor to keep your worker alive.

    Login or Signup to reply.
  2. so what you need here to solve the issue is to do the following steps :

    1. go to bootstrap/cache/ remove all file .PHP
    2. go to the src and run php artisan queue:restart
    3. Now after adding the snippet, we need to trigger the following commands respectively:
    • sudo supervisorctl reread (to check the file content and make sure
      that the snippet is correctly set)
    • sudo supervisorctl update (release the config changes under the supervisor)
    • sudo supervisorctl restart all (re-trigger the queues so that the newly created queue gets initialized and start picking up messages respectively)
    Login or Signup to reply.
  3. I solved this by increasing memory limit public like this in my code

    $tries = 10;
    
        public $timeout = 4000;
        protected $news;
    
        public function __construct($news)
        {
            ini_set('memory_limit', '4048M');
            $this->news = $news;
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search