John Davidson

Laravel queues not working without php artisan queue:work command

0 comments
Message:


My queue is working perfectly, when i run the following command php artisan queue:work
I’m using database as a QUEUE_DRIVER. On the server i don’t run the above command every-time.


for eg:


In schedule we have to run the command php artisan schedule:work. In this case on server we register this in cronetab like this:


* * * * * php /path/of/the/project/artisan schedule:run 1>> /dev/null 2>&1


Then we don’t have to run schedule work command again and again.


Is something also for queue. So we don’t have to run php artisan queue:work again and again. Also i don’t want to change the driver.



My Answer:
If your Laravel queues are not working without running the `php artisan queue:work` command manually, you may need to set up a process to continuously run the queue worker on your server.

One way to do this is by using Supervisor, a process control system for Unix-like operating systems. Supervisor can be used to monitor and control processes, such as the Laravel queue worker, ensuring that it is always running.

Here's how you can set up Supervisor to run the queue worker on your server:

1. Install Supervisor on your server if it is not already installed. You can typically do this using a package manager such as apt or yum.

2. Create a new Supervisor configuration file for your Laravel queue worker. You can create a new configuration file in the `/etc/supervisor/conf.d/` directory, for example `laravel-queue-worker.conf`.

3. In the configuration file, specify the command to run the queue worker. For example:


[program:laravel-queue-worker]
command=php /path/to/your/project/artisan queue:work --sleep=3 --tries=3
directory=/path/to/your/project
autostart=true
autorestart=true
stderr_logfile=/var/log/laravel-queue-worker.err.log
stdout_logfile=/var/log/laravel-queue-worker.out.log


4. Save the configuration file and reload Supervisor to apply the changes:


sudo supervisorctl reread
sudo supervisorctl update


5. Start the Laravel queue worker process using Supervisor:


sudo supervisorctl start laravel-queue-worker


Now, Supervisor will ensure that the Laravel queue worker process is always running on your server, even if you do not manually run the `php artisan queue:work` command.

Rate this post

3 of 5 based on 1396 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us