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.
We can install pm2 using
npm with the following command :
npm install pm2 -g
Configure PM2 file for Laravel queue
your-worker-name.yml in your laravel project folder, you can put the file in root folder or create a new folder such as
- name: your-worker-name
Open a terminal from root of the Laravel project folder, and run these following command.
pm2 start your-worker-name.yml
// Or if you put pm2 file not in root folder
pm2 start worker/your-worker-name.yml
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…