DEV Community

Raiyan Memon
Raiyan Memon

Posted on

Running Laravel Queue Worker in Production

Laravel Queue Worker plays an important role in running in the background. It does not put a load on our web application.

For firing mail and any other stuff that takes time for such tasks, we can schedule a queue worker.

In this we are going to see how we can schedule our queue worker on the production server.

Most people including me had a hard time running this command on the production server we can just keep running “php artisan queue:work” every time so I got the solution.

Go inside your code folder on the server and just place this command and hit enter twice.

nohup php artisan queue:work --daemon &

Congratulations! You just fired a command which will keep the worker running even if you close the console of your server.

One more thing if you have made any changes in the queue worker code and something related to that and the changes do not reflect on the production link just restart the queue with this command.

php artisan queue:restart

This will stop the command of keeping up the queue worker and then run

php artisan optimize:clear

This command is mandatory because Laravel stores the cache and does not clear it by default.

After this just hit the first command and your queue worker is automated again.

Keep coding and exploring❤️

Top comments (0)