centos下安装supervisor的步骤详解


本文摘自PHP中文网,作者不言,侵删。

本篇文章给大家带来的内容是关于centos下安装supervisor的步骤详解,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

1、安装supervisor

执行以下命令

1

2

yum install python-setuptools

easy_install supervisor

或者

1

2

3

4

5

6

#如果easy_install不好使就从官方下载:

wget https://pypi.python.org/packages/80/37/964c0d53cbd328796b1aeb7abea4c0f7b0e8c7197ea9b0b9967b7d004def/supervisor-3.3.1.tar.gz

#然后通过python安装:

tar zxf supervisor-3.3.1.tar.gz

cd supervisor

python setup.py install

2、配置Supervisor

a.创建文件夹和配置文件

1

2

mkdir /etc/supervisor

echo_supervisord_conf > /etc/supervisor/supervisord.conf

b.修改/etc/supervisor/supervisord.conf文件内容
在文件结尾[include]节点处
把;files = relative/directory/*.ini

1141144388-5c1259d744aff_articlex.png

改为files = conf.d/*.conf

12440190-5c125a3d1d8bd_articlex.png

c.执行supervisorctl reload命令使配置文件生效。
d.在/etc/supervisor/下创建conf.d文件夹,及ProjectName.conf(以项目名称命名的)
e.打开laravel.conf文件,添加内容如下:

1

2

3

4

5

6

7

8

9

[program:laravel]

process_name=%(program_name)s_%(process_num)02d

command=/usr/local/php/bin/php /data/wwwroot/laravel/artisan queue:listen --tries=3

autostart=true

autorestart=true

user=www

numprocs=2

redirect_stderr=true

stdout_logfile=/data/wwwlogs/worker.log

3、运行supervisord,查看是否生效,执行以下命令:

1

2

3

4

#运行

supervisord -c /etc/supervisor/supervisord.conf

#查看进程 (ps -ef | grep ProjectName)

ps -ef|grep laravel

4、配置supervisord开机启动

a.在指定目录下创建文件supervisord.service

1

vim /usr/lib/systemd/system/supervisord.service

b.输入以下内容:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

[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

c.执行以下命令:

1

systemctl enable supervisord

d.验证是否为开机启动:

1

2

#提示 enabled 表示成功

systemctl is-enabled supervisord

5、常用命令

1

2

3

4

5

6

service supervisord start #启动

service supervisord stop #停止

service supervisord status #状态

supervisorctl shutdown #关闭所有任务

supervisorctl stop|start program_name #启动或停止服务

supervisorctl status #查看所有任务状态

以上就是centos下安装supervisor的步骤详解的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

Linux <怎么用

如何在whm/cpanel中更改主域的文档根目录

Linux如何重启nginx?

Linux网络不可达

如何在创建模板之后通过ecs控制台新建版本

Linux中关于mkdir命令的详解

怎么修改Linux文件

Linux怎么解压tar.gz

判断Linux是64位还是32位

Linux怎么编译

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...