I am using Laravel queues in my application, I have following configuration,
.env:
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
config/queue.config
'default' => env('QUEUE_CONNECTION', 'sync'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
]
]
I have setup supervisor and it has following configuration
/etc/supervisor/conf.d/laravel_queue.sh
[program:laravel_queue]
process_name=%(program_name)s_%(process_num)02d
command=php /usr/local/bin/run_queue.sh
startsecs = 0
autostart=true
autorestart=true
user=root
redirect_stderr=true
stderr_logfile=/var/log/laraqueue.err.log
stdout_logfile=/var/log/laraqueue.out.log
/usr/local/bin/run_queue.sh
php /var/www/myproject/artisan queue:work --tries=1
Problem:
When I set QUEUE_CONNECTION=sync it works fine, but jobs are executed synchronously. I want them to execute asynchronously. So when I set QUEUE_CONNECTION=database my jobs are not executed at all and I can see them sitting in my jobs table.
I have also observed that when I run php artisan queue:work directly from my project's directory it works as expected, that is jobs are executed asynchronously.
Any help in this regard is much appreciated.
/usr/local/bin/run_queue.sh?