tyldar's avatar

Queue job timeout

Hello world!

I'm running Laravel queue with that command :

/usr/bin/php7.2 artisan queue:listen --timeout=0

But the process keeps stopping at 300 seconds with that error :

Symfony\Component\Process\Exception\ProcessTimedOutException(code: 0): The process [...] exceeded the timeout of 300 seconds

I've also tried to set timeout in job's class :

public $timeout = 5000;

Anyone know what to do? This process is for video encoding so a bit long running, I need the timeout to be ~1 hour.

I've already configured php.ini for both cli and apache2 (configured on 0 to disable builtin php timeout)

Thx!

0 likes
4 replies
salmon's avatar

I solved a similar issue by adding redis as my queue driver

.env QUEUE_DRIVER=redis

And then I installed supervisor in my docker/server to overcome the 300 sec timeout limitation.

Initially I tried the setup without supervisor, but it meant I had to run the command --timeout=5000 every time. ( Note: --timeout command only works for PHP 7.1 or greater)

Now that I have set supervisor up, I can just trigger my jobs that has the timeout setup on the job itself or globally on the supervisor config.

Dockerfile

#install lumen Supervisor for Job Queues
RUN apt-get install -y --allow-unauthenticated supervisor

# Configure supervisor
# Add supervisor conf file
COPY lumen-worker.conf /etc/supervisor/conf.d/laravel-worker.conf
# Give execution rights on the supervisor conf file
RUN chmod 0644 /etc/supervisor/conf.d/laravel-worker.conf
# Create the log file to be able to run tail
RUN touch /var/log/supervisor/worker.log

... at end

CMD supervisord && supervisorctl start all  -D FOREGROUND

lumen-worker.conf

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/web-app/artisan queue:work --daemon --sleep=3 --tries=1
autostart=true
autorestart=true
user=www-data
numprocs=4
redirect_stderr=true
stdout_logfile=/var/log/supervisor/worker.log
salmon's avatar

Was this what you were looking for?

tyldar's avatar

No. I'm already using redis/supervisor and I guess this is caused by pure apache configuration but I can't manage to get it working.

If I do : php -r "phpinfo();" | grep execution_time

I get : max_execution_time => 0 => 0

So I guess Apache config is good, it's the Laravel config that get stuck.

salmon's avatar

What do you get when you run

supervisorctl status all

on your server

Please or to participate in this conversation.