supervisor

安装

yum install epel-release
yum install -y supervisor

 

配置 

默认配置文件:/etc/supervisord.conf
进程管理配置文件放到:/etc/supervisord.d/目录下即可

进程配置文件如下实例:

[program:test-server]
process_name=%(program_name)s
command = /usr/local/php/bin/php /home/wwwroot/default/suzhou/artisan queue:work --daemon --timeout=60 --sleep=3 --tries=3
directory = /home/test-server
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root         #此处很重要当前登录账号
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 10
stdout_logfile = /var/log/test-server.log

  

 

启动

启动时指向配置 

supervisord -c /etc/supervisor/supervisord.conf

 

 

 错误处理:

出现以下错误是 user 配置了不存在账户名

 

 

使用

supervisorctr restart start stop 

配置Supervisor开机启动:

新建一个“supervisord.service”文件

# dservice 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

  

将文件拷贝至:“/usr/lib/systemd/system/supervisord.service”

systemctl enable supervisord

clip_image001

验证一下是否为开机启动:

systemctl is-enabled supervisord

clip_image002

 

 

问题1 :unix:///tmp/supervisor.sock no such file

问题1 :Can't drop privilege as nonroot user

运行命令:

 

supervisorctl shutdown

 

 

posted @ 2018-09-26 22:52  知子  阅读(212)  评论(0编辑  收藏  举报