新闻动态
新闻动态
NEWS INFORMATION

centos7使用supervisor的详细教程

发布日期:2022-06-20 12:20 | 文章来源:源码之家

supervisor是用Python开发的一套通用的进程管理程序,可以将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时可以自动重启

安装supervisor

# yum search setuptools
....
python-setuptools.noarch : Easily build and distribute Python packages
 
#yum install -y python-setuptools.noarch
 
#easy_install supervisor

创建主配置文件

# mkdir -m 755 -p /etc/supervisor   
\\创建supervisor配置文件目录
# echo_supervisord_conf >/etc/supervisor/supervisord.conf 
\\创建主配置文件
# cd /etc/supervisor/
# mkdir -m 755 conf.d    
\\创建项目配置文件目录

创建项目配置文件(运行3个脚本)

# vim conf.d/test.ini
[program:tjapp_sendmessage]
command=/bin/bash /data/shell/sendmessage.sh
numprocs=1
autostart=true
autorestart=true
 
[program:bbscollection]
command=/bin/bash /data/shell/bbscollection.sh
numprocs=1
autostart=true
autorestart=true
 
[program:test_sbbscollection]
command=/bin/bash /data/shell/test_sbbscollection.sh
numprocs=1
autostart=true
autorestart=true

在主配置文件中引入test.ini

#cat supervisord.conf
...
[include]
files = ./conf.d/*.ini

启动supervisor

# supervisord -c /etc/supervisord.conf

查看supervisor运行的脚本

# supervisorctl
bbscollection     RUNNING pid 10090, uptime 4 days, 17:20:10
test_sbbscollection    RUNNING pid 10088, uptime 4 days, 17:20:10
tjapp_sendmessage    RUNNING pid 10089, uptime 4 days, 17:20:10

停止bbscollection脚本

# supervisorctl stop bbscollection
bbscollection: stopped
[root@om-web_test supervisord.d]# supervisorctl
bbscollection   STOPPED Apr 06 10:23 AM
test_sbbscollection  RUNNING pid 10088, uptime 4 days, 17:23:13
tjapp_sendmessage  RUNNING pid 10089, uptime 4 days, 17:23:13
 
supervisor> start bbscollection \\启动
 
supervisor> status
bbscollection   RUNNING pid 7310, uptime 0:00:24
test_sbbscollection  RUNNING pid 10088, uptime 4 days, 17:23:54
tjapp_sendmessage  RUNNING pid 10089, uptime 4 days, 17:23:54

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。

香港服务器租用

版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。

实时开通

自选配置、实时开通

免备案

全球线路精选!

全天候客户服务

7x24全年不间断在线

专属顾问服务

1对1客户咨询顾问

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部