0
votes

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

1
what happens if you replace this handle with a simpler version such as "echo, log only" to see whether it is related to the code or something else. Don't forget to restart the queueErsoy
@Ersoy I did that. And that keep the queue alive with all the echo's showing in the terminal. So it is something with my code. But it is weird that it reaches the end of the code the job has to process. And then stop. So unlink is the last line. I added an extra log after the unlink. And that logges correctSamir
Do you think any script or command may be executing php artisan queue:restart (cron, minutely command etc maybe) - this command ends every running process after the completion.Ersoy
Nope. I checked the code again. And there are np signs of a restart command or something that could kill the queueSamir

1 Answers

0
votes

Did you tried queue:listen ?

php artisan queue:listen

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