supervisor [Installation and use of articles] of process management tools

When using Tp message queue think-queue process that led to the end of the project can not accidentally run!;

So use the supervisor; next to share with you their experiences as well as the use of the methods used to install;

Official website: HTTP: //supervisord.org/introd ...
First, there are many ways to install;
01: wget to download the compressed package:

cd /usr/local/lee   #这个lee是我自己建立的一个目录
wget https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/supervisor-3.3.2.tar.gz
tar -zxvf supervisor-3.3.2.tar.gz cd supervisor-3.3.2 python setup.py install

02: yum install:

yum install python-setuptools
easy_install supervisor

When we use the wget installed;
5b5888b468e0e.png

5b5888cf26f49.png

5b5888e4a6449.png

After generating the configuration file:

mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisord.conf

Open the configuration file to modify something;

vim /etc/supervisord.conf

To the bottom of the

;[include]
;files = relative/directory/*.ini
修改为:
[include]
files=/etc/supervisor/*.conf 
(注意去掉分号,第一次安装的时候就因为没去掉分号出现了问题!);

After you create a random file name suffix .conf, and I am here to create a test.conf file;
my project under / www / wwwroot / admin / directory:

vim test.conf
#写入一些配置:
[program:test]   # 设置进程的名称,使用 supervisorctl 来管理进程时需要使用该进程名 我这里就叫做test了!
command=php think queue:work --queue saveLoginLog --daemon --tries 10;  #这个就是队列执行的命令
directory= /www/wwwroot/admin;  #命令执行的目录或者说执行 command 之前,先切换到工作目录 可以理解为在执行命令前会切换到这个目录
process_name=%(process_num)02d; #默认为 %(program_name)s,即 [program:x] 中的 x 这个是进程名,如果我们下面的numprocs参数为1的话,就不用管这个参数 了,它默认值%(program_name)s也就是上面的那个program冒号后面的 numprocs=5; #进程数量当不为1时的时候,就是进程池的概念,注意process_name的设置 autostart=true; #是否自动启动 autorestart=true; #程序意外退出是否自动重启 startsecs=1; 自动重启间隔 startretries=20; 当进程启动失败后,最大尝试启动的次数。。当超过3次后,supervisor将把此进程的状态置为FAIL 默认值为3 。。 redirect_stderr=true; 如果为true,则stderr的日志会被写入stdout日志文件中 理解为重定向输出的日志 user=root; 这个参数可以设置一个非root用户,当我们以root用户启动supervisord之后。我这里面设置的这个用户,也可以对supervisord进行管理 stdout_logfile= /www/wwwroot/admin/test.out.log; 子进程的stdout的日志路径 输出日志文件 stderr_logfile=/www/wwwroot/admin/test.err.log ; 错误日志文件 当redirect_stderr=true。这个就不用

There are explanatory notes above looks a bit confusing, we did not write a comment:

[program:test] 
command=php think queue:work --queue saveLoginLog --daemon --tries 10
directory= /www/wwwroot/admin
process_name=%(process_num)02d numprocs=5 autostart=true autorestart=true startsecs=1 startretries=20 redirect_stderr=true user=root stdout_logfile= /www/wwwroot/admin/test.out.log stderr_logfile=/www/wwwroot/admin/test.err.log 

After performing start:

supervisord -c /etc/supervisord.conf
supervisorctl reload

5b588a07dce5a.png

I encountered an error in the course of implementation, the following will say the wrong issues addressed and solutions;

Now let's test;
executed first stop will be at the time of the test process stops, and then open a terminal after connection redis, we perform a login queue after performing the task after login will always exist in redis;

supervisorctl stop test 或者直接 supervisorctl stop all

5b588ab662a08.png

You can see is not being executed! Now we open the test process supervisorctl
5b5887de1f28b.png

5b588ac471aa8.png

接下来说一下问题:
问题1:
Unlinking stale socket /tmp/supervisor.sock
或者:
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.

5b588add37fa1.png

5b588ae748e75.png

Solution:

sudo unlink /tmp/supervisor.sock 
or
sudo unlink /var/run/supervisor.sock

问题2:
gave up: redis entered FATAL state, too many start retries too quickly

Solution:

Redis.conf is no modification of daemonize

Other issues do not find;
when I was in the process of testing actually kill off can be performed, so the server restart!

Guess you like

Origin www.cnblogs.com/xingxia/p/supervisor_install_use.html