Home  >  Article  >  PHP Framework  >  Teach you to use supervisor to manage laravel resident task (queue, etc.) configuration

Teach you to use supervisor to manage laravel resident task (queue, etc.) configuration

藏色散人
藏色散人forward
2020-10-26 14:07:102875browse

The following tutorial column will introduce to you how to use supervisor to manage the configuration of laravel resident tasks (queues, etc.). I hope it will be helpful to friends in need!

In the production environment, a reliable process management tool is needed to help laravel maintain the status of the task process. Supervisor is a very wide choiceTeach you to use supervisor to manage laravel resident task (queue, etc.) configuration

1. Install supervisor

ubuntu environment:

apt install supervisor

2. Configure supervisor

The configuration file has two locations: Main configuration file: /etc/supervisor/supervisord.conf

Usually used to configure global configuration

Personalized configuration file :
/etc/supervisor/conf.d/*.conf Usually used to configure the personalized configuration of a single process group or process, similar to placing multiple servers in separate configuration files when configuring nginx. Supervisor configuration documentation: https://www.rddoc.com/doc/Supervisor/3.3.1/zh/configuration/#supervisord-section-settings

3. For example:

// 在/etc/supervisor/conf.d/路径下建立一个 foo.conf 文件,存放一个组名为foo的配置
[group:foo] // 建立一个进程组
programs=bar // 进程组包括的进程,多个进程用逗号隔开

[program:bar] // 建立一个进程
process_name=%(program_name)s_%(process_num)02d // 启动的进程名 : bar_00 bar_01 ...
command=php /data/www/laravel-path/artisan queue:work --sleep=3 --tries=3 // 执行的进程命令
autostart=true // 随supervisor启动自动启动
autorestart=true
user=deploy // 执行进程的用户
numprocs=8 // 进程数
redirect_stderr=true
stdout_logfile=/data/logs/foo.log
Start supervisor: supervisord -c /etc/supervisord.conf

Enter supervisor console:

supervisorctl

supervisorctl> reread // 读取新增加的配置
supervisorctl> update
supervisorctl> start foo:* //启动foo组下的所有进程

The above is the detailed content of Teach you to use supervisor to manage laravel resident task (queue, etc.) configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete