'What's the most convenient way to run queue:work on production?
I'm working on a digital product based on laravel. In which i use laravel queued jobs.
While creating the documentation I've figured out that it's not that familiar to run the queue listener/worker on production for non-tech clients.
Is there any kind of easy way to achieve that without setting up a process monitor or a job sheduler?
I've tried to create a route where clients can run Artisan::call('queue:work --once') whenever they have dispatched jobs, but it seems not a good idea.
Any help?
Solution 1:[1]
This is the exact reason why you need a Daemon, so for example Supervisor as a tool is great fit. Read this section out of Laravel Docs (copied below) https://laravel.com/docs/9.x/queues#supervisor-configuration
And if you are using Laravel Forge, or Vapor, then it's a breeze!
sudo apt-get install supervisor
Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored. For example, let's create a laravel-worker.conf file that starts and monitors queue:work processes:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work sqs --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log
stopwaitsecs=3600
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mo Kawsara |
