Movatterモバイル変換


[0]ホーム

URL:


Sitemap
Open in app

Press enter or click to view image in full size
Photo byJaime Dantas onUnsplash

In production, we need to keep ourartisan queue:work running. For some reasonartisan queue:work process may stop running. So we need a process monitor that keep ourartisan 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 usingnpm with the following command :

npm install pm2 -g

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

apps:
- name: your-worker-name
script: artisan
exec_mode: fork
interpreter: php
instances: 1
args:
- queue:work
- --tries=5
- --sleep=1

Run PM2
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

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

Press enter or click to view image in full size
Monitoring pm2

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/

--

--

Responses (1)


[8]ページ先頭

©2009-2025 Movatter.jp