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