Centos7
安装supervisor
easy_install supervisor
生成配置文件
echo_supervisord_conf > /etc/supervisor/supervisord.conf
编辑生成的配置文件,把include块的注释去掉:
[include]
files=/etc/supervisor/conf.d/*.conf
相关文件是默认放在/tmp下的,需要更改路径
在/etc/supervisor/conf.d/目录下新增一个laravel-worker.conf文件
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /usr/share/nginx/html/tanteng.me/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
设置开机启动,创建/usr/lib/systemd/system/supervisord.service文件并写入一下内容:
# supervisord service for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
加入开机启动
systemctl enable supervisord
systemctl is-enabled supervisord
网友评论