Run and Monitor Laravel Queue using PM2

Photo by Jaime Dantas on Unsplash

In production, we need to keep our artisan queue:work running. For some reason artisan queue:work process may stop running. So we need a process monitor that keep our artisan queue:work running and monitoring running queue.

Based on Laravel documentation, process monitor used to run and monitor a queue is Supervisor. In this post I will use pm2 instead of supervisor. PM2 is a daemon process manager that will help you manage and keep your application online 24/7.

Install PM2
We can install pm2 using npm with the following command :

Configure PM2 file for Laravel queue
Create your-worker-name.yml in your laravel project folder, you can put the file in root folder or create a new folder such as /worker .

Run PM2
Open a terminal from root of the Laravel project folder, and run these following command.

Monitoring PM2
To monitor running Laravel queue, we can use pm2 list command and here is the result.

That’s all that I can share from this post, please feel free to leave a coment for any suggestions or questions. Thanks for read my post. See yaa…

References
1. https://laravel.com/docs/8.x/queues#supervisor-configuration
2. https://pm2.keymetrics.io/

--

--

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store